From 4122736deda3aac69d2874ffc7e0b04e58a41249 Mon Sep 17 00:00:00 2001 From: adamdebek Date: Wed, 12 Jul 2023 13:09:02 +0200 Subject: [PATCH] lsb-vsx: overall clean up --- lsb_vsx_posix/Makefile | 2 +- lsb_vsx_posix/lsb_vsx_posix.c | 14 +++++++------- trunner/harnesses/factory.py | 34 ---------------------------------- 3 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 trunner/harnesses/factory.py diff --git a/lsb_vsx_posix/Makefile b/lsb_vsx_posix/Makefile index 13a3b1e1e..24f5bbd35 100644 --- a/lsb_vsx_posix/Makefile +++ b/lsb_vsx_posix/Makefile @@ -1,4 +1,4 @@ NAME := lsb_vsx_posix LOCAL_SRCS := lsb_vsx_posix.c -include $(binary.mk) \ No newline at end of file +include $(binary.mk) diff --git a/lsb_vsx_posix/lsb_vsx_posix.c b/lsb_vsx_posix/lsb_vsx_posix.c index 9f59c4525..47358e469 100644 --- a/lsb_vsx_posix/lsb_vsx_posix.c +++ b/lsb_vsx_posix/lsb_vsx_posix.c @@ -12,7 +12,6 @@ int main(int argc, char **argv) const char *cmd_single_test = "/usr/test/lsb_vsx_posix/files/bin/tcc -p -e -s /usr/test/lsb_vsx_posix/files/test_sets/scen_single.exec -j -"; const char *cmd_clean = "/usr/test/lsb_vsx_posix/files/bin/tcc -p -c -s /usr/test/lsb_vsx_posix/files/test_sets/scen_single.exec"; const char *cwd = "/usr/test/lsb_vsx_posix/files/test_sets"; - const char *resultPath = "/usr/test/lsb_vsx_posix/files/test_sets/results"; char *line = NULL; char total[40]; @@ -27,7 +26,7 @@ int main(int argc, char **argv) return 1; } - /* Set necessary enviroment variables */ + /* Set necessary environment variables */ if (setenv("TET_ROOT", "/usr/test/lsb_vsx_posix/files", 0) != 0) { perror("setenv() - setting \"TET_ROOT\" failed"); return 1; @@ -42,17 +41,17 @@ int main(int argc, char **argv) if (argc == 2) { /* File containing all tests */ all_tests_f = fopen("/usr/test/lsb_vsx_posix/files/test_sets/scen.exec", "r"); - if (all_tests_f == -1) { + if (all_tests_f == NULL) { perror("fopen"); exit(EXIT_FAILURE); } /* File which we gonna pass to tcc, this file will contain 2 required lines and one test name */ single_test_f = open("/usr/test/lsb_vsx_posix/files/test_sets/scen_single.exec", O_WRONLY | O_CREAT | O_TRUNC); - if (single_test_f == NULL) { + if (single_test_f == -1) { perror("fopen"); exit(EXIT_FAILURE); } - /* append "all" to start of scenario file in order to follow file format*/ + /* append "all" to start of scenario file in order to follow file format */ write(single_test_f, "all\n", 5); while ((nread = getline(&line, &len, all_tests_f)) != -1) { @@ -61,7 +60,8 @@ int main(int argc, char **argv) * the line we need will reside in buffer "total". */ if (strstr(line, "total tests in") != NULL) { - strncpy(total, line, 40); + strncpy(total, line, 39); + total[40] = '\0'; } if (strstr(line, argv[1]) != NULL) { /* Write second line */ @@ -69,7 +69,7 @@ int main(int argc, char **argv) /* Write test name */ write(single_test_f, line, nread); - /*Test found, everything we need written, so close and clean */ + /* Test found, everything we need written, so close and clean */ fclose(all_tests_f); close(single_test_f); free(line); diff --git a/trunner/harnesses/factory.py b/trunner/harnesses/factory.py deleted file mode 100644 index 4b63666c8..000000000 --- a/trunner/harnesses/factory.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# Phoenix-RTOS test runner -# -# Harnesses for test frameworks supported in the Test Runner - factory -# -# Copyright 2022 Phoenix Systems -# Authors: Damian Loewnau, Jakub SarzyƄski, Piotr Nieciecki -# - -from .unity import UnitTestHarness -from .busybox import BusyboxTestHarness -from .mbedtls import MbedtlsTestHarness -from .micropython import MicropythonStandardHarness -from .micropython import MicropythonReplHarness -from .lsb_vsx_posix import LsbVsxPosixTestHarness - - -class TestHarnessFactory: - @staticmethod - def create(test_type): - if test_type == 'unit': - return UnitTestHarness() - if test_type == 'busybox': - return BusyboxTestHarness() - if test_type == 'mbedtls': - return MbedtlsTestHarness() - if test_type == 'micropython_std': - return MicropythonStandardHarness() - if test_type == 'micropython_repl': - return MicropythonReplHarness() - if test_type == 'lsb_vsx_posix': - return LsbVsxPosixTestHarness() - else: - raise ValueError(f"Unknown test type: {test_type}")