1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3source ../tests/engine.sh 4test_begin 5 6set_timeout 30s 7 8# Help tests 9check "verify kunit subcommand help" \ 10 "$RVGEN kunit -h" 0 "model_name" "spec" 11 12check_and_compare_folder "KUnit generation with local lookup and test_da_kunit" \ 13 "$RVGEN monitor -c da -s tests/specs/test_da.dot -t per_cpu -n test_da_kunit && $RVGEN kunit -a -l -n test_da_kunit" \ 14 "test_da_kunit" "Now complete the test and add it to rv_monitors_test.c" "RV_MON_OPS_INIT" 15 16check_and_compare_folder "KUnit generation with local lookup and test_ha_kunit" \ 17 "$RVGEN monitor -c ha -s tests/specs/test_ha.dot -t per_task -n test_ha_kunit && $RVGEN kunit -a -l -n test_ha_kunit" \ 18 "test_ha_kunit" "Successfully created KUnit" "Append the following to" 19 20check_and_compare_folder "KUnit generation with local lookup and test_ltl_kunit" \ 21 "$RVGEN monitor -c ltl -s tests/specs/test_ltl.ltl -t per_task -n test_ltl_kunit && $RVGEN kunit -l -n test_ltl_kunit" \ 22 "test_ltl_kunit" "RV_MON_OPS_INIT" 23 24check_and_compare_folder "KUnit generation with backup file" \ 25 "$RVGEN monitor -c ltl -s tests/specs/test_ltl.ltl -t per_task -n test_bak_kunit && echo DUMMY > test_bak_kunit/test_bak_kunit_kunit.c && $RVGEN kunit -l -n test_bak_kunit" \ 26 "test_bak_kunit" "KUnit file(s) already exist.*backing up existing files" 27 28# Error handling tests 29check "missing required model_name" \ 30 "$RVGEN kunit" 2 "the following arguments are required: -n/--model_name" 31 32check "non-existent model_name with auto_patch" \ 33 "$RVGEN kunit -a -n nonexistent" 1 \ 34 "Could not find monitor C file" "Traceback (most recent call last)" 35 36check "monitor without handlers" \ 37 "mkdir -p nohandler ; echo DUMMY > nohandler/nohandler.c ; $RVGEN kunit -l -n nohandler" 1 \ 38 "No handlers found" "Traceback (most recent call last)" 39rm -rf nohandler 40 41test_end 42