Skip to content

Commit 5e3b171

Browse files
committed
Add more tests for start_ursim.sh
1 parent 96dfeba commit 5e3b171

File tree

2 files changed

+145
-2
lines changed

2 files changed

+145
-2
lines changed

scripts/start_ursim.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ parse_arguments(){
274274
\?) # invalid option
275275
echo "Error: Invalid option"
276276
help
277-
exit;;
277+
exit 1
278278
esac
279279
done
280280
}
@@ -392,7 +392,7 @@ main() {
392392

393393
if [ "$TEST_RUN" = true ]; then
394394
echo "$docker_cmd" | tr -s ' '
395-
exit
395+
exit 0
396396
fi
397397
$docker_cmd || exit 2
398398

tests/test_start_ursim.bats

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,146 @@ setup() {
294294
echo "Robot model is: $ROBOT_MODEL"
295295
[ "$ROBOT_MODEL" = "UR30" ]
296296
}
297+
298+
@test "help_prints_fine" {
299+
run main -h
300+
[ $status -eq 0 ]
301+
}
302+
303+
@test "setting_urcap_storage" {
304+
run main -t
305+
echo "$output"
306+
[ $status -eq 0 ]
307+
urcap_mount=$(echo "$output" | tail -n1 | grep -Po "\-v\ [\/\w+\.\-]+:\/urcaps" | cut -d ':' -f1 | cut -d " " -f 2)
308+
[ "$urcap_mount" = "$HOME/.ursim/e-series/urcaps" ]
309+
310+
run main -t -v 3.14.3
311+
echo "$output"
312+
[ $status -eq 0 ]
313+
urcap_mount=$(echo "$output" | tail -n1 | grep -Po "\-v\ [\/\w+\.\-]+:\/urcaps" | cut -d ':' -f1 | cut -d " " -f 2)
314+
[ "$urcap_mount" = "$HOME/.ursim/cb3/urcaps" ]
315+
316+
target_dir=$(mktemp -d)
317+
run main -u "$target_dir" -t
318+
echo "$output"
319+
[ $status -eq 0 ]
320+
urcap_mount=$(echo "$output" | tail -n1 | grep -Po "\-v\ [\/\w+\.\-]+:\/urcaps" | cut -d ':' -f1 | cut -d " " -f 2)
321+
[ "$urcap_mount" = "$target_dir" ]
322+
323+
}
324+
325+
@test "setting_program_storage" {
326+
run main -t
327+
echo "$output"
328+
[ $status -eq 0 ]
329+
program_mount=$(echo "$output" | tail -n1 | grep -Po "\-v\ [\/\w+\.\-]+:\/ursim\/programs" | cut -d ':' -f1 | cut -d " " -f 2)
330+
[ "$program_mount" = "$HOME/.ursim/e-series/ur5e/programs" ]
331+
332+
run main -t -v 3.14.3
333+
echo "$output"
334+
[ $status -eq 0 ]
335+
program_mount=$(echo "$output" | tail -n1 | grep -Po "\-v\ [\/\w+\.\-]+:\/ursim\/programs" | cut -d ':' -f1 | cut -d " " -f 2)
336+
[ "$program_mount" = "$HOME/.ursim/cb3/ur5/programs" ]
337+
338+
run main -t -v 10.7.0
339+
echo "$output"
340+
[ $status -eq 0 ]
341+
program_mount=$(echo "$output" | tail -n1 | grep -Po "\-v\ [\/\w+\.\-]+:\/ur\/bin\/backend\/applications" | cut -d ':' -f1 | cut -d " " -f 2)
342+
[ "$program_mount" = "$HOME/.ursim/polyscopex/ur5e/programs" ]
343+
344+
target_dir=$(mktemp -d)
345+
run main -p "$target_dir" -t
346+
echo "$output"
347+
[ $status -eq 0 ]
348+
program_mount=$(echo "$output" | tail -n1 | grep -Po "\-v\ [\/\w+\.\-]+:\/ursim\/programs" | cut -d ':' -f1 | cut -d " " -f 2)
349+
[ "$program_mount" = "$target_dir" ]
350+
}
351+
352+
@test "setting_ip_addresss" {
353+
run main -t -i 123.123.123.123
354+
echo "$output"
355+
[ $status -eq 0 ]
356+
ip_address=$(echo "$output" | tail -n1 | grep -o -E "\-\-ip ([0-9]+\.?)+" | cut -d " " -f2)
357+
[ "$ip_address" = "123.123.123.123" ]
358+
}
359+
360+
@test "default_port_forwarding_cb3" {
361+
run main -t -v 3.14.3
362+
echo "$output"
363+
[ $status -eq 0 ]
364+
port_forwarding=$(echo "$output" | tail -n -1 | grep -Eo "(\-p\s*[0-9]+(\-[0-9]+)?:[0-9]+(\-[0-9]+)?\s*)+" | awk '{$1=$1};1')
365+
[ "$port_forwarding" = "$PORT_FORWARDING_WITH_DASHBOARD" ]
366+
}
367+
368+
@test "default_port_forwarding_e-series" {
369+
run main -t -v 5.21.0
370+
echo "$output"
371+
[ $status -eq 0 ]
372+
port_forwarding=$(echo "$output" | tail -n -1 | grep -Eo "(\-p\s*[0-9]+(\-[0-9]+)?:[0-9]+(\-[0-9]+)?\s+)+" | awk '{$1=$1};1')
373+
[ "$port_forwarding" = "$PORT_FORWARDING_WITH_DASHBOARD" ]
374+
}
375+
376+
@test "default_port_forwarding_polyscopex" {
377+
run main -t -v 10.7.0
378+
echo "$output"
379+
[ $status -eq 0 ]
380+
port_forwarding=$(echo "$output" | tail -n -1 | grep -Eo "(\-p\s*[0-9]+(\-[0-9]+)?:[0-9]+(\-[0-9]+)?\s*)+" | awk '{$1=$1};1')
381+
[ "$port_forwarding" = "$PORT_FORWARDING_WITHOUT_DASHBOARD" ]
382+
}
383+
384+
@test "setting_port_forwarding" {
385+
run main -t -f "-p 1234:1234 -p 50001-50004:60001-60004"
386+
echo "$output"
387+
[ $status -eq 0 ]
388+
port_forwarding=$(echo "$output" | tail -n -1 | grep -Eo "(\-p\s*[0-9]+(\-[0-9]+)?:[0-9]+(\-[0-9]+)?\s*)+" | awk '{$1=$1};1')
389+
[ "$port_forwarding" = "-p 1234:1234 -p 50001-50004:60001-60004" ]
390+
}
391+
392+
@test "default_container_name" {
393+
run main -t
394+
echo "$output"
395+
[ $status -eq 0 ]
396+
container_name=$(echo "$output" | tail -n -1 | grep -o -E "\-\-name\s\w+" | cut -d " " -f2)
397+
[ "$container_name" = "ursim" ]
398+
}
399+
400+
@test "setting_container_name_cb3" {
401+
run main -t -n "ursim_test" -v 3.14.3
402+
echo "$output"
403+
[ $status -eq 0 ]
404+
container_name=$(echo "$output" | tail -n -1 | grep -o -E "\-\-name\s\w+" | cut -d " " -f2)
405+
[ "$container_name" = "ursim_test" ]
406+
}
407+
408+
@test "setting_container_name_e-series" {
409+
run main -t -n "ursim_test" -v 5.21.0
410+
echo "$output"
411+
[ $status -eq 0 ]
412+
container_name=$(echo "$output" | tail -n -1 | grep -o -E "\-\-name\s\w+" | cut -d " " -f2)
413+
[ "$container_name" = "ursim_test" ]
414+
}
415+
416+
@test "setting_container_name_polyscopex" {
417+
run main -t -n "ursim_test" -v 10.7.0
418+
echo "$output"
419+
[ $status -eq 0 ]
420+
container_name=$(echo "$output" | tail -n -1 | grep -o -E "\-\-name\s\w+" | cut -d " " -f2)
421+
[ "$container_name" = "ursim_test" ]
422+
}
423+
424+
@test "catch_unknown_parameters" {
425+
run main -t -x
426+
echo "$output"
427+
[ $status -eq 1 ]
428+
}
429+
430+
@test "not_detached_by_default" {
431+
test_input_handling
432+
[ "$DETACHED" = "false" ]
433+
}
434+
435+
@test "setting_detached_argument" {
436+
test_input_handling -d
437+
[ "$DETACHED" = "true" ]
438+
}
439+

0 commit comments

Comments
 (0)