| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2016 Jeromy Johnson |
| 4 | # MIT Licensed; see the LICENSE file in this repository. |
| 5 | # |
| 6 | |
| 7 | test_description="Test active request commands" |
| 8 | |
| 9 | . lib/test-lib.sh |
| 10 | |
| 11 | test_init_ipfs |
| 12 | test_launch_ipfs_daemon |
| 13 | |
| 14 | test_expect_success "command works" ' |
| 15 | ipfs diag cmds > cmd_out |
| 16 | ' |
| 17 | |
| 18 | test_expect_success "invoc shows up in output" ' |
| 19 | grep "diag/cmds" cmd_out > /dev/null |
| 20 | ' |
| 21 | |
| 22 | test_expect_success "start longer running command" ' |
| 23 | ipfs log tail & |
| 24 | LOGPID=$! |
| 25 | go-sleep 100ms |
| 26 | ' |
| 27 | |
| 28 | test_expect_success "long running command shows up" ' |
| 29 | ipfs diag cmds > cmd_out2 |
| 30 | ' |
| 31 | |
| 32 | test_expect_success "output looks good" ' |
| 33 | grep "log/tail" cmd_out2 | grep "true" > /dev/null |
| 34 | ' |
| 35 | |
| 36 | test_expect_success "kill log cmd" ' |
| 37 | kill $LOGPID |
| 38 | go-sleep 0.5s |
| 39 | kill $LOGPID |
| 40 | |
| 41 | wait $LOGPID || true |
| 42 | ' |
| 43 | |
| 44 | test_expect_success "long running command inactive" ' |
| 45 | ipfs diag cmds > cmd_out3 |
| 46 | ' |
| 47 | |
| 48 | test_expect_success "command shows up as inactive" ' |
| 49 | grep "log/tail" cmd_out3 | grep "false" |
| 50 | ' |
| 51 | |
| 52 | test_kill_ipfs_daemon |
| 53 | test_done |