#! /bin/sh # First argument needs to be the name of the script. if [ $# -eq 0 ] then echo "Please give a name to your test i.e ./s_new_test my_test" exit 128 fi # Check if the test already exists. FILE=../test/cppsuite/tests/$1.cxx if test -f "$FILE"; then echo "$FILE cannot be created as it already exists." exit 1 fi # Check if default configuration associated to the test already exists. CONFIG=../test/cppsuite/configs/config_$1_default.txt if test -f "$CONFIG"; then echo "$CONFIG cannot be created as it already exists." exit 1 fi # Copy the default template. cp ../test/cppsuite/tests/example_test.cxx $FILE echo "created $FILE." cp ../test/cppsuite/configs/config_example_test_default.txt $CONFIG echo "created $CONFIG." # Replace example_test with the new test name. sed -i "s/example_test/$1/" $FILE echo "updated $FILE." # Replace the first line of the configuration file. REPLACE="# Configuration for $1." sed -i "1s/.*/$REPLACE/" $CONFIG echo "updated $CONFIG." # Include the new test in run.cxx FILE=../test/cppsuite/tests/run.cxx SEARCH="#include \"example_test.cxx\"" VALUE="#include \"$1.cxx\"" sed -i "/$SEARCH/a $VALUE" $FILE # Add the new test to the run_test() method SEARCH="example_test(config, test_name).run()" LINE_1="\ else if (test_name == \"$1\")\n" LINE_2="\ $1(config, test_name).run();" sed -i "/$SEARCH/a $LINE_1$LINE_2" $FILE # Add the new test to all existing tests. SEARCH="all_tests = {\"example_test\"" REPLACE="$SEARCH, \"$1\"" sed -i "s/$SEARCH/$REPLACE/" $FILE echo "Updated $FILE." # Add the new test to test_data.py FILE=test_data.py SEARCH="example_test" LINE_1="\ '$1' : Method(test_config)," sed -i "/$SEARCH/a $LINE_1" $FILE echo "Updated $FILE." # Trigger s_all echo "Running s_all.." ./s_all # Last changes to be done manually echo "Follow the next steps to execute your new test to the framework:" echo "1. Start editing $1.cxx" echo "2. Build your changes, go to build_posix/test/cppsuite and run your test with ./run -t $1"