@@ -12,11 +12,12 @@ cleanup () {
1212 if [ -n " $PARSEC_PID " ]; then kill $PARSEC_PID || true ; fi
1313 # Stop tpm_server if running
1414 if [ -n " $TPM_SRV_PID " ]; then kill $TPM_SRV_PID || true ; fi
15- # Remove the slot_number line added by find_slot_number.sh
16- sed -i ' /^slot_number =.*/d ' $CONFIG_PATH
15+ # Remove the slot_number line added earlier
16+ find e2e_tests -name " *toml " -not -name " Cargo.toml " -exec sed -i ' s /^slot_number =.*/# slot_number/ ' {} \;
1717 # Remove fake mapping and temp files
18- if [ -d " mappings" ]; then rm -rf -- " mappings" ; fi
19- if [ -f " NVChip" ]; then rm " NVChip" ; fi
18+ rm -rf " mappings"
19+ rm -f " NVChip"
20+ rm -f " e2e_tests/provider_cfg/tmp_config.toml"
2021
2122 if [ -z " $NO_CARGO_CLEAN " ]; then cargo clean; fi
2223}
@@ -50,6 +51,7 @@ error_msg () {
5051NO_CARGO_CLEAN=
5152NO_STRESS_TEST=
5253PROVIDER_NAME=
54+ CONFIG_PATH=$( pwd) /e2e_tests/provider_cfg/tmp_config.toml
5355while [ " $# " -gt 0 ]; do
5456 case " $1 " in
5557 --no-cargo-clean )
@@ -63,7 +65,7 @@ while [ "$#" -gt 0 ]; do
6365 error_msg " Only one provider name must be given"
6466 fi
6567 PROVIDER_NAME=$1
66- CONFIG_PATH= " e2e_tests/provider_cfg/$1 /config.toml"
68+ cp $( pwd ) / e2e_tests/provider_cfg/$1 /config.toml $CONFIG_PATH
6769 if [ " $PROVIDER_NAME " = " all" ]; then
6870 FEATURES=" --features=all-providers"
6971 else
@@ -94,8 +96,13 @@ if [ "$PROVIDER_NAME" = "tpm" ] || [ "$PROVIDER_NAME" = "all" ]; then
9496fi
9597
9698if [ " $PROVIDER_NAME " = " pkcs11" ] || [ " $PROVIDER_NAME " = " all" ]; then
97- # Find and append the slot number at the end of the configuration file.
98- e2e_tests/provider_cfg/pkcs11/find_slot_number.sh $CONFIG_PATH
99+ pushd e2e_tests
100+ # This command suppose that the slot created by the container will be the first one that appears
101+ # when printing all the available slots.
102+ SLOT_NUMBER=` softhsm2-util --show-slots | head -n2 | tail -n1 | cut -d " " -f 2`
103+ # Find all TOML files in the directory (except Cargo.toml) and replace the commented slot number with the valid one
104+ find . -name " *toml" -not -name " Cargo.toml" -exec sed -i " s/^# slot_number.*$/slot_number = $SLOT_NUMBER /" {} \;
105+ popd
99106fi
100107
101108echo " Build test"
@@ -128,6 +135,7 @@ pgrep -f target/debug/parsec >/dev/null
128135if [ " $PROVIDER_NAME " = " all" ]; then
129136 echo " Execute all-providers tests"
130137 RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml all_providers
138+ RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml config
131139else
132140 # Per provider tests
133141 echo " Execute normal tests"
0 commit comments