<commit_before>#!/bin/sh

set -eu

TEST_DIR=$(dirname "$0")

# shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh"

test_teardown()
{
	say "Test done $(date)"
	say "Running test teardown."

	texec rm -f "$FINIT_CONF"
	texec rm -f /test_assets/fserv
}

say "Test start $(date)"

cp "$TEST_DIR"/common/fserv "$TENV_ROOT"/test_assets/

say "Add service stanza in $FINIT_CONF"
texec sh -c "echo 'service [2345] pid:!/run/fserv.pid /test_assets/fserv -- Forking service' > $FINIT_CONF"

say 'Reload Finit'
#texec sh -c "initctl debug"
texec sh -c "initctl reload"
#texec sh -c "initctl status"
#texec sh -c "ps"

# Wait for process to fork, create its PID file so Finit can register
# its new PID -- this is the major difference from regular services.
sleep 2

#texec sh -c "initctl status"
#texec sh -c "ps"
#texec sh -c "initctl status fserv"

retry 'assert_num_children 1 fserv'

say 'Stop the service'
texec sh -c "initctl stop fserv"

retry 'assert_num_children 0 fserv'

say 'Start the service again'
texec sh -c "initctl start fserv"

retry 'assert_num_children 1 fserv'<commit_msg>test: fserv is built in another directory<commit_after>#!/bin/sh

set -eu

TEST_DIR=$(dirname "$0")

# shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh"

test_teardown()
{
	say "Test done $(date)"
	say "Running test teardown."

	texec rm -f "$FINIT_CONF"
	texec rm -f /test_assets/fserv
}

say "Test start $(date)"

cp "$TENV_ROOT"/../common/fserv "$TENV_ROOT"/test_assets/

say "Add service stanza in $FINIT_CONF"
texec sh -c "echo 'service [2345] pid:!/run/fserv.pid /test_assets/fserv -- Forking service' > $FINIT_CONF"

say 'Reload Finit'
#texec sh -c "initctl debug"
texec sh -c "initctl reload"
#texec sh -c "initctl status"
#texec sh -c "ps"

# Wait for process to fork, create its PID file so Finit can register
# its new PID -- this is the major difference from regular services.
sleep 2

#texec sh -c "initctl status"
#texec sh -c "ps"
#texec sh -c "initctl status fserv"

retry 'assert_num_children 1 fserv'

say 'Stop the service'
texec sh -c "initctl stop fserv"

retry 'assert_num_children 0 fserv'

say 'Start the service again'
texec sh -c "initctl start fserv"

retry 'assert_num_children 1 fserv'
{'fraction_non_alphanumeric': 0.12159709618874773, 'fraction_numerical': 0.008166969147005444, 'mean_word_length': 4.104166666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7427700', 'n_tokens_mistral': 857, 'n_tokens_neox': 836, 'n_words': 295}