From 0ccbd8197678818b4d10af0427ac3adb876e4ecc Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Mon, 27 Jan 2025 15:11:57 +0000 Subject: [PATCH] Added failing test to show that we add single quotes around environment variable values Signed-off-by: Stefan Marr --- rebench/tests/bugs/env_quote.conf | 22 +++++++++++++ rebench/tests/bugs/env_quote_test.py | 46 ++++++++++++++++++++++++++++ rebench/tests/bugs/env_quote_vm.py | 13 ++++++++ 3 files changed, 81 insertions(+) create mode 100644 rebench/tests/bugs/env_quote.conf create mode 100644 rebench/tests/bugs/env_quote_test.py create mode 100755 rebench/tests/bugs/env_quote_vm.py diff --git a/rebench/tests/bugs/env_quote.conf b/rebench/tests/bugs/env_quote.conf new file mode 100644 index 00000000..fad780f1 --- /dev/null +++ b/rebench/tests/bugs/env_quote.conf @@ -0,0 +1,22 @@ +default_experiment: Test + +benchmark_suites: + Suite: + gauge_adapter: Time + command: TestBenchMarks %(benchmark)s %(warmup)s + benchmarks: + - Bench1 + env: + LUA_PATH: "?.lua;../../awfy/Lua/?.lua" + +executors: + TestRunner1: + path: . + executable: env_quote_vm.py + +experiments: + Test: + suites: + - Suite + executions: + - TestRunner1 diff --git a/rebench/tests/bugs/env_quote_test.py b/rebench/tests/bugs/env_quote_test.py new file mode 100644 index 00000000..f633bc7d --- /dev/null +++ b/rebench/tests/bugs/env_quote_test.py @@ -0,0 +1,46 @@ +# Copyright (c) 2009-2025 Stefan Marr +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +from ...configurator import Configurator, load_config +from ...executor import Executor +from ...persistence import DataStore + +from ..rebench_test_case import ReBenchTestCase + + +class EnvQuoteTest(ReBenchTestCase): + + def setUp(self): + super(EnvQuoteTest, self).setUp() + self._set_path(__file__) + + def test_execution_should_recognize_invalid_run_and_continue_normally(self): + cnf = Configurator( + load_config(self._path + "/env_quote.conf"), + DataStore(self.ui), + self.ui, + data_file=self._tmp_file, + ) + runs = list(cnf.get_runs()) + self.assertEqual(runs[0].get_number_of_data_points(), 0) + + ex = Executor([runs[0]], False, self.ui) + ex.execute() + + self.assertEqual(runs[0].get_number_of_data_points(), 1) diff --git a/rebench/tests/bugs/env_quote_vm.py b/rebench/tests/bugs/env_quote_vm.py new file mode 100755 index 00000000..53f60e4a --- /dev/null +++ b/rebench/tests/bugs/env_quote_vm.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import os +import sys + +# get the environemnt variable LUA_PATH +lua_path = os.environ.get("LUA_PATH", "") +if lua_path == "?.lua;../../awfy/Lua/?.lua": + print("Correct") + sys.exit(0) +else: + print("Error: LUA_PATH has unexpected value: " + lua_path) + print("Previously we has stray single quotes around the value.") + sys.exit(1)