Skip to content

Commit d0e67ce

Browse files
committed
Enforce sub-scripts are not called directly
1 parent f89277e commit d0e67ce

File tree

8 files changed

+49
-15
lines changed

8 files changed

+49
-15
lines changed

scripts/cmd_test/aes-cmd-test.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
# aes-cmd-test.sh
33
# AES encryption test for wolfProvider
44
#
5-
# NOTE: This script is designed to be called from do-cmd-tests.sh
6-
# Do not run this script directly - use do-cmd-tests.sh instead
7-
#
85
# Copyright (C) 2006-2025 wolfSSL Inc.
96
#
107
# This file is part of wolfProvider.
@@ -25,6 +22,13 @@
2522
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2623
source "${SCRIPT_DIR}/cmd-test-common.sh"
2724
source "${SCRIPT_DIR}/clean-cmd-test.sh"
25+
26+
if [ -z "${DO_CMD_TESTS:-}" ]; then
27+
echo "This script is designed to be called from do-cmd-tests.sh"
28+
echo "Do not run this script directly - use do-cmd-tests.sh instead"
29+
exit 1
30+
fi
31+
2832
cmd_test_init "aes-test.log"
2933
clean_cmd_test "aes"
3034

scripts/cmd_test/clean-cmd-test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with wolfProvider. If not, see <http://www.gnu.org/licenses/>.
1919

20+
if [ -z "${DO_CMD_TESTS:-}" ]; then
21+
echo "This script is designed to be called from do-cmd-tests.sh"
22+
echo "Do not run this script directly - use do-cmd-tests.sh instead"
23+
exit 1
24+
fi
25+
2026
# Function to clean up specific command test artifacts
2127
clean_cmd_test() {
2228
local test_type=$1

scripts/cmd_test/cmd-test-common.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ WOLFPROV_REPLACE_DEFAULT=${WOLFPROV_REPLACE_DEFAULT:-0}
2323
WOLFPROV_FIPS=${WOLFPROV_FIPS:-0}
2424
WOLFPROV_INSTALLED=${WOLFPROV_INSTALLED:-0}
2525

26+
if [ -z "${DO_CMD_TESTS:-}" ]; then
27+
echo "This script is designed to be called from do-cmd-tests.sh"
28+
echo "Do not run this script directly - use do-cmd-tests.sh instead"
29+
exit 1
30+
fi
31+
2632
# Function to detect wolfProvider installation mode
2733
detect_wolfprovider_mode() {
2834
if [ -z "${REPO_ROOT:-}" ]; then

scripts/cmd_test/do-cmd-tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2424
REPO_ROOT="$( cd "${SCRIPT_DIR}/../.." &> /dev/null && pwd )"
2525
UTILS_DIR="${REPO_ROOT}/scripts"
2626

27+
# Flag to indicate that this script is being called from do-cmd-tests.sh
28+
export DO_CMD_TESTS=1
29+
2730
# Parse command-line arguments
2831
RUN_HASH=0
2932
RUN_AES=0

scripts/cmd_test/ecc-cmd-test.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
# ecc-cmd-test.sh
33
# ECC key generation test for wolfProvider
44
#
5-
# NOTE: This script is designed to be called from do-cmd-tests.sh
6-
# Do not run this script directly - use do-cmd-tests.sh instead
7-
#
85
# Copyright (C) 2006-2025 wolfSSL Inc.
96
#
107
# This file is part of wolfProvider.
@@ -25,6 +22,13 @@
2522
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2623
source "${SCRIPT_DIR}/cmd-test-common.sh"
2724
source "${SCRIPT_DIR}/clean-cmd-test.sh"
25+
26+
if [ -z "${DO_CMD_TESTS:-}" ]; then
27+
echo "This script is designed to be called from do-cmd-tests.sh"
28+
echo "Do not run this script directly - use do-cmd-tests.sh instead"
29+
exit 1
30+
fi
31+
2832
cmd_test_init "ecc-test.log"
2933
clean_cmd_test "ecc"
3034

scripts/cmd_test/hash-cmd-test.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
# hash-cmd-test.sh
33
# Run hash command-line tests for wolfProvider
44
#
5-
# NOTE: This script is designed to be called from do-cmd-tests.sh
6-
# Do not run this script directly - use do-cmd-tests.sh instead
7-
#
85
# Copyright (C) 2006-2025 wolfSSL Inc.
96
#
107
# This file is part of wolfProvider.
@@ -25,6 +22,13 @@
2522
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2623
source "${SCRIPT_DIR}/cmd-test-common.sh"
2724
source "${SCRIPT_DIR}/clean-cmd-test.sh"
25+
26+
if [ -z "${DO_CMD_TESTS:-}" ]; then
27+
echo "This script is designed to be called from do-cmd-tests.sh"
28+
echo "Do not run this script directly - use do-cmd-tests.sh instead"
29+
exit 1
30+
fi
31+
2832
cmd_test_init "hash-test.log"
2933
clean_cmd_test "hash"
3034

scripts/cmd_test/req-cmd-test.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
# req-cmd-test.sh
33
# Certificate request test for wolfProvider
44
#
5-
# NOTE: This script is designed to be called from do-cmd-tests.sh
6-
# Do not run this script directly - use do-cmd-tests.sh instead
7-
#
85
# Copyright (C) 2006-2025 wolfSSL Inc.
96
#
107
# This file is part of wolfProvider.
@@ -25,6 +22,13 @@
2522
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2623
source "${SCRIPT_DIR}/cmd-test-common.sh"
2724
source "${SCRIPT_DIR}/clean-cmd-test.sh"
25+
26+
if [ -z "${DO_CMD_TESTS:-}" ]; then
27+
echo "This script is designed to be called from do-cmd-tests.sh"
28+
echo "Do not run this script directly - use do-cmd-tests.sh instead"
29+
exit 1
30+
fi
31+
2832
cmd_test_init "req-test.log"
2933
clean_cmd_test "req"
3034

scripts/cmd_test/rsa-cmd-test.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
# rsa-cmd-test.sh
33
# RSA and RSA-PSS key generation test for wolfProvider
44
#
5-
# NOTE: This script is designed to be called from do-cmd-tests.sh
6-
# Do not run this script directly - use do-cmd-tests.sh instead
7-
#
85
# Copyright (C) 2006-2025 wolfSSL Inc.
96
#
107
# This file is part of wolfProvider.
@@ -28,6 +25,12 @@ source "${SCRIPT_DIR}/clean-cmd-test.sh"
2825
cmd_test_init "rsa-test.log"
2926
clean_cmd_test "rsa"
3027

28+
if [ -z "${DO_CMD_TESTS:-}" ]; then
29+
echo "This script is designed to be called from do-cmd-tests.sh"
30+
echo "Do not run this script directly - use do-cmd-tests.sh instead"
31+
exit 1
32+
fi
33+
3134
# Create test data and output directories
3235
mkdir -p rsa_outputs
3336
echo "This is test data for RSA signing and verification." > rsa_outputs/test_data.txt

0 commit comments

Comments
 (0)