1#!/usr/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2025 Oxide Computer Company 15# 16 17# Load the required ktest module 18if ! ktest load ktest; then 19 exit 1 20fi 21 22echo "Running status tests" 23echo "Some are expected to emit non-PASS results" 24ktest run -n -p -o "test,result" ktest:selftest: | awk -F: ' 25BEGIN { 26 expect["ktest_st_none_test"] = "NONE"; 27 expect["ktest_st_pass_test"] = "PASS"; 28 expect["ktest_st_fail_test"] = "FAIL"; 29 expect["ktest_st_err_test"] = "ERROR"; 30 expect["ktest_st_skip_test"] = "SKIP"; 31 expect["ktest_st_mult_result_test"] = "ERROR"; 32 expect["ktest_st_unique_test"] = "PASS"; 33 expect["ktest_st_name_test"] = "PASS"; 34 35 expected_count = 8; 36 37 test_count = 0; 38 issue_count = 0; 39} 40/:/ { 41 print $0 42 test_count += 1; 43 if ($1 in expect) { 44 if (expect[$1] != $2) { 45 printf "Unexpected status for test %s, %s != %s\n", 46 $1, $2, expect[$1]; 47 issue_count += 1; 48 } 49 } else { 50 printf "unexpected test %s\n" $1 51 issue_count += 1; 52 } 53} 54END { 55if (test_count != expected_count) { 56 printf "Did not encount expected number of tests: %d != %d\n", 57 test_count, expected_count; 58 issue_count += 1; 59 } 60 if (issue_count != 0) { 61 print "Errors detected" 62 exit 1 63 } 64} 65' 66exit $? 67