mirror of https://github.com/martanne/abduco
Merge 40b2714221 into 8c32909a15
This commit is contained in:
commit
fce1134f74
6
abduco.1
6
abduco.1
|
|
@ -25,6 +25,10 @@
|
|||
.Cm command Op args ...
|
||||
.
|
||||
.Nm
|
||||
.Fl d
|
||||
.Cm name
|
||||
.
|
||||
.Nm
|
||||
.Fl n
|
||||
.Op options ...
|
||||
.Cm name
|
||||
|
|
@ -84,6 +88,8 @@ Attach to an existing session.
|
|||
Try to connect to an existing session, upon failure create said session and attach immediately to it.
|
||||
.It Fl c
|
||||
Create a new session and attach immediately to it.
|
||||
.It Fl d
|
||||
Detect if the specified session exists, returning a successful exit status if true.
|
||||
.It Fl n
|
||||
Create a new session but do not attach to it.
|
||||
.El
|
||||
|
|
|
|||
10
abduco.c
10
abduco.c
|
|
@ -606,11 +606,12 @@ int main(int argc, char *argv[]) {
|
|||
server.name = basename(argv[0]);
|
||||
gethostname(server.host+1, sizeof(server.host) - 1);
|
||||
|
||||
while ((opt = getopt(argc, argv, "aAclne:fpqrv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "aAcdlne:fpqrv")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
case 'A':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'n':
|
||||
action = opt;
|
||||
break;
|
||||
|
|
@ -712,6 +713,13 @@ int main(int argc, char *argv[]) {
|
|||
goto redo;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
if (session_exists(server.session_name)) {
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
28
testsuite.sh
28
testsuite.sh
|
|
@ -171,6 +171,33 @@ run_test_dvtm() {
|
|||
fi
|
||||
}
|
||||
|
||||
run_test_detect_session() {
|
||||
check_environment || return 1;
|
||||
|
||||
local name="$1"
|
||||
local cmd="$2"
|
||||
local output="$name.out"
|
||||
local output_expected="$name.expected"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
echo -n "Running test: $name "
|
||||
$cmd >/dev/null 2>&1
|
||||
expected_abduco_epilog "$name" $? > "$output_expected" 2>&1
|
||||
|
||||
if detach | $ABDUCO $ABDUCO_OPTS -c "$name" $cmd >/dev/null 2>&1 && sleep 3 &&
|
||||
$ABDUCO -d "$name" &&
|
||||
$ABDUCO -a "$name" 2>&1 | tail -1 | sed 's/.$//' > "$output" &&
|
||||
diff -u "$output_expected" "$output" && check_environment; then
|
||||
rm "$output" "$output_expected"
|
||||
TESTS_OK=$((TESTS_OK + 1))
|
||||
echo "OK"
|
||||
return 0
|
||||
else
|
||||
echo "FAIL"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
test_non_existing_command || echo "Execution of non existing command FAILED"
|
||||
|
||||
run_test_attached "awk" "awk 'BEGIN {for(i=1;i<=1000;i++) print i}'"
|
||||
|
|
@ -207,6 +234,7 @@ EOT
|
|||
chmod +x long-running.sh
|
||||
|
||||
run_test_attached_detached "attach-detach" "./long-running.sh"
|
||||
run_test_detect_session "detect-session" "./long-running.sh"
|
||||
|
||||
rm ./long-running.sh
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue