tests - fix cp and end_fun for LinuxTest

This commit is contained in:
bunkerity 2022-07-19 16:06:50 +02:00
parent 2505bc015f
commit 6f35561fae
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
2 changed files with 10 additions and 9 deletions

View File

@ -81,23 +81,18 @@ class LinuxTest(Test) :
try :
super()._setup_test()
test = "/tmp/tests/" + self._name
example_data = "./examples/" + self._name + "/bw-data"
for ex_domain, test_domain in self._domains.items() :
Test.replace_in_files(test, ex_domain, test_domain)
Test.rename(test, ex_domain, test_domain)
Test.replace_in_files(test, "example.com", getenv("ROOT_DOMAIN"))
setup = test + "/setup-linux.sh"
if isfile(setup) :
proc = LinuxTest.docker_cp(self.__distro, "/tmp/" + self._name, "/opt/tests")
proc = LinuxTest.docker_cp(self.__distro, test, "/opt/tests")
if proc.returncode != 0 :
raise(Exception("docker cp failed (linux stack)"))
proc = LinuxTest.docker_exec(self.__distro, "cd /opt/tests/" + self._name + " && ./setup-linux.sh")
proc = LinuxTest.docker_exec(self.__distro, "cd /opt/tests/ && ./setup-linux.sh")
if proc.returncode != 0 :
raise(Exception("docker exec setup failed (linux stack)"))
if isdir(example_data) :
for cp_dir in listdir(example_data) :
if isdir(join(example_data, cp_dir)) :
copytree(join(example_data, cp_dir), join("/tmp/bw-data", cp_dir))
proc = LinuxTest.docker_exec(self.__distro, "systemctl restart bunkerweb")
if proc.returncode != 0 :
raise(Exception("docker exec systemctl restart failed (linux stack)"))

View File

@ -70,11 +70,17 @@ for example in glob("./examples/*") :
test_obj = LinuxTest(tests["name"], tests["timeout"], tests["tests"], distro)
if not test_obj.run_tests() :
log("TESTS", "", "Tests failed for " + tests["name"])
end_fun()
if test_type == "linux" :
ret = end_fun(distro)
else :
ret = end_fun()
_exit(1)
except :
log("TESTS", "", "Exception while executing test for example " + example + " : " + format_exc())
end_fun()
if test_type == "linux" :
ret = end_fun(distro)
else :
ret = end_fun()
exit(1)
if test_type == "linux" :