Skip to content

Commit

Permalink
Add integration test for add/rm dep via dinitctl
Browse files Browse the repository at this point in the history
  • Loading branch information
davmac314 committed Jun 23, 2020
1 parent 71b59c9 commit 5469480
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/igr-tests/add-rm-dep/expected1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[{+} ] main
[{+} ] secondary
Empty file.
2 changes: 2 additions & 0 deletions src/igr-tests/add-rm-dep/expected3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[{+} ] main
[ {-}] secondary
Empty file.
1 change: 1 addition & 0 deletions src/igr-tests/add-rm-dep/expected5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Service started.
58 changes: 58 additions & 0 deletions src/igr-tests/add-rm-dep/run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh

../../dinit -d sd -u -p socket -q main &
DINITPID=$!

# give time for socket to open
while [ ! -e socket ]; do
sleep 0.1
done

STATUS=FAIL

DINITCTL="../../dinitctl -p socket"

while

out=$($DINITCTL list)
if [ $? != 0 ]; then break; fi
if [ "$out" != "$(cat expected1)" ]; then break; fi
# both "main" and "secondary" should be running

out=$($DINITCTL rm-dep waits-for main secondary)
if [ $? != 0 ]; then break; fi
if [ "$out" != "$(cat expected2)" ]; then break; fi
# "secondary" should stop

out=$($DINITCTL list)
if [ $? != 0 ]; then break; fi
if [ "$out" != "$(cat expected3)" ]; then break; fi

out=$($DINITCTL add-dep waits-for main secondary)
if [ $? != 0 ]; then break; fi
if [ "$out" != "$(cat expected4)" ]; then break; fi
# "secondary" will not automatically start, this is a waits-for dep

out=$($DINITCTL list)
if [ $? != 0 ]; then break; fi
if [ "$out" != "$(cat expected3)" ]; then break; fi

out=$($DINITCTL wake secondary)
if [ $? != 0 ]; then break; fi
if [ "$out" != "$(cat expected5)" ]; then break; fi
# if we wake "secondary" it should start and remain started

out=$($DINITCTL list)
if [ $? != 0 ]; then break; fi
if [ "$out" != "$(cat expected1)" ]; then break; fi

STATUS=PASS
false

do :; done

kill $DINITPID
wait $DINITPID

if [ $STATUS = PASS ]; then exit 0; fi
exit 1
2 changes: 2 additions & 0 deletions src/igr-tests/add-rm-dep/sd/main
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type = internal
waits-for = secondary
1 change: 1 addition & 0 deletions src/igr-tests/add-rm-dep/sd/secondary
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type = internal
2 changes: 1 addition & 1 deletion src/igr-tests/igr-runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern char **environ;
int main(int argc, char **argv)
{
const char * const test_dirs[] = { "basic", "environ", "ps-environ", "chain-to", "force-stop", "restart",
"check-basic", "check-cycle", "reload1", "reload2", "no-command-error" };
"check-basic", "check-cycle", "reload1", "reload2", "no-command-error", "add-rm-dep" };
constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);

int passed = 0;
Expand Down

0 comments on commit 5469480

Please sign in to comment.