#!/bin/bash
#
-# Copyright 2024 Nordix Foundation.
+# Copyright 2024-2025 OpenInfra Foundation Europe. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Default test profile is kpi.
testProfile=${1:-kpi}
+# Cleanup handler: capture exit status, run teardown,
+# and restore directory, report failures, and exit with original code.
on_exit() {
rc=$?
./teardown.sh "$testProfile"
echo "TEST FAILURES: $rc"
exit $rc
}
-trap on_exit EXIT
+
+# Call on_exit, on script exit (EXIT) or when interrupted (SIGINT, SIGTERM, SIGQUIT) to perform cleanup
+trap on_exit EXIT SIGINT SIGTERM SIGQUIT
pushd "$(dirname "$0")" || exit 1