1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4# This runs all known tests across all known possible configurations we could
5# emulate in one run.
6
7set -e
8
9TEST_DIR=$(dirname $0)
10source $TEST_DIR/fw_lib.sh
11
12export HAS_FW_LOADER_USER_HELPER=""
13export HAS_FW_LOADER_USER_HELPER_FALLBACK=""
14
15run_tests()
16{
17	proc_set_force_sysfs_fallback $1
18	proc_set_ignore_sysfs_fallback $2
19	$TEST_DIR/fw_filesystem.sh
20
21	proc_set_force_sysfs_fallback $1
22	proc_set_ignore_sysfs_fallback $2
23	$TEST_DIR/fw_fallback.sh
24}
25
26run_test_config_0001()
27{
28	echo "-----------------------------------------------------"
29	echo "Running kernel configuration test 1 -- rare"
30	echo "Emulates:"
31	echo "CONFIG_FW_LOADER=y"
32	echo "CONFIG_FW_LOADER_USER_HELPER=n"
33	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
34	run_tests 0 1
35}
36
37run_test_config_0002()
38{
39	echo "-----------------------------------------------------"
40	echo "Running kernel configuration test 2 -- distro"
41	echo "Emulates:"
42	echo "CONFIG_FW_LOADER=y"
43	echo "CONFIG_FW_LOADER_USER_HELPER=y"
44	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
45	proc_set_ignore_sysfs_fallback 0
46	run_tests 0 0
47}
48
49run_test_config_0003()
50{
51	echo "-----------------------------------------------------"
52	echo "Running kernel configuration test 3 -- android"
53	echo "Emulates:"
54	echo "CONFIG_FW_LOADER=y"
55	echo "CONFIG_FW_LOADER_USER_HELPER=y"
56	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y"
57	run_tests 1 0
58}
59
60check_mods
61check_setup
62
63if [ -f $FW_FORCE_SYSFS_FALLBACK ]; then
64	run_test_config_0001
65	run_test_config_0002
66	run_test_config_0003
67else
68	echo "Running basic kernel configuration, working with your config"
69	run_tests
70fi
71