6 echo "Beginning of the functional tests"
8 echo ">>>>> get help <<<<<"
9 coverage run -a --branch bin/kconfig-hardened-check
10 coverage run -a --branch bin/kconfig-hardened-check -h
12 echo ">>>>> get version <<<<<"
13 coverage run -a --branch bin/kconfig-hardened-check --version
15 echo ">>>>> print the security hardening recommendations <<<<<"
16 coverage run -a --branch bin/kconfig-hardened-check -p X86_64
17 coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m verbose
18 coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m json
20 coverage run -a --branch bin/kconfig-hardened-check -p X86_32
21 coverage run -a --branch bin/kconfig-hardened-check -p X86_32 -m verbose
22 coverage run -a --branch bin/kconfig-hardened-check -p X86_32 -m json
24 coverage run -a --branch bin/kconfig-hardened-check -p ARM64
25 coverage run -a --branch bin/kconfig-hardened-check -p ARM64 -m verbose
26 coverage run -a --branch bin/kconfig-hardened-check -p ARM64 -m json
28 coverage run -a --branch bin/kconfig-hardened-check -p ARM
29 coverage run -a --branch bin/kconfig-hardened-check -p ARM -m verbose
30 coverage run -a --branch bin/kconfig-hardened-check -p ARM -m json
32 echo ">>>>> generate the Kconfig fragment <<<<<"
33 coverage run -a --branch bin/kconfig-hardened-check -g X86_64
34 coverage run -a --branch bin/kconfig-hardened-check -g X86_32
35 coverage run -a --branch bin/kconfig-hardened-check -g ARM64
36 coverage run -a --branch bin/kconfig-hardened-check -g ARM
38 echo ">>>>> check the example kconfig files and cmdline <<<<<"
40 echo "l1tf=off mds=full randomize_kstack_offset=on iommu.passthrough=0" > ./cmdline_example
42 CONFIG_DIR=`find . -name config_files`
43 KCONFIGS=`find $CONFIG_DIR -type f | grep -e "\.config" -e "\.gz"`
47 COUNT=$(expr $COUNT + 1)
48 echo "\n>>>>> checking kconfig number $COUNT <<<<<"
49 coverage run -a --branch bin/kconfig-hardened-check -c $C > /dev/null
50 coverage run -a --branch bin/kconfig-hardened-check -c $C -m verbose > /dev/null
51 coverage run -a --branch bin/kconfig-hardened-check -c $C -l /proc/cmdline > /dev/null
52 coverage run -a --branch bin/kconfig-hardened-check -c $C -l ./cmdline_example > /dev/null
53 coverage run -a --branch bin/kconfig-hardened-check -c $C -l ./cmdline_example -m verbose > /dev/null
54 coverage run -a --branch bin/kconfig-hardened-check -c $C -l ./cmdline_example -m json > /dev/null
55 coverage run -a --branch bin/kconfig-hardened-check -c $C -l ./cmdline_example -m show_ok > /dev/null
56 coverage run -a --branch bin/kconfig-hardened-check -c $C -l ./cmdline_example -m show_fail > /dev/null
58 echo "\n>>>>> have checked $COUNT kconfigs <<<<<"
60 echo "Collect coverage for error handling"
61 echo ">>>>> lonely -l <<<<<"
62 ! coverage run -a --branch bin/kconfig-hardened-check -l /proc/cmdline
64 echo ">>>>> wrong modes for -p <<<<<"
65 ! coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m show_ok
66 ! coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -m show_fail
68 echo ">>>>> -p and -c together <<<<<"
69 ! coverage run -a --branch bin/kconfig-hardened-check -p X86_64 -c kconfig_hardened_check/config_files/distros/fedora_34.config
71 echo ">>>>> wrong mode for -g <<<<<"
72 ! coverage run -a --branch bin/kconfig-hardened-check -g X86_64 -m show_ok
74 echo ">>>>> -g and -c together <<<<<"
75 ! coverage run -a --branch bin/kconfig-hardened-check -g X86_64 -c kconfig_hardened_check/config_files/distros/fedora_34.config
77 cp kconfig_hardened_check/config_files/distros/fedora_34.config ./test.config
79 echo ">>>>> no kernel version <<<<<"
80 sed '3d' test.config > error.config
81 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
83 echo ">>>>> strange kernel version string <<<<<"
84 sed '3 s/5./version 5./' test.config > error.config
85 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
87 echo ">>>>> no arch <<<<<"
88 sed '305d' test.config > error.config
89 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
91 echo ">>>>> more than one arch <<<<<"
92 cp test.config error.config
93 echo 'CONFIG_ARM64=y' >> error.config
94 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
96 echo ">>>>> invalid disabled kconfig option <<<<<"
97 sed '28 s/is not set/is not set yet/' test.config > error.config
98 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
100 echo ">>>>> invalid enabled kconfig option <<<<<"
101 cp test.config error.config
102 echo 'CONFIG_FOO=is not set' >> error.config
103 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
105 echo ">>>>> one config option multiple times <<<<<"
106 cp test.config error.config
107 echo 'CONFIG_BUG=y' >> error.config
108 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
110 echo ">>>>> invalid compiler versions <<<<<"
111 cp test.config error.config
112 sed '8 s/CONFIG_CLANG_VERSION=0/CONFIG_CLANG_VERSION=120000/' test.config > error.config
113 ! coverage run -a --branch bin/kconfig-hardened-check -c error.config
115 echo ">>>>> multi-line cmdline file <<<<<"
116 echo 'hey man 1' > cmdline
117 echo 'hey man 2' >> cmdline
118 ! coverage run -a --branch bin/kconfig-hardened-check -c test.config -l cmdline
120 echo "The end of the functional tests"