Skip to content

Commit

Permalink
lsb-vsx: overall clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdebek committed Jul 13, 2023
1 parent 348d646 commit 2483a3a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 68 deletions.
2 changes: 1 addition & 1 deletion lsb_vsx_posix/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME := lsb_vsx_posix
LOCAL_SRCS := lsb_vsx_posix.c

include $(binary.mk)
include $(binary.mk)
21 changes: 11 additions & 10 deletions lsb_vsx_posix/lsb_vsx_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/stat.h>

int main(int argc, char **argv)
{
const char *cmd_all_tests = "/usr/test/lsb_vsx_posix/files/bin/tcc -p -e -s /usr/test/lsb_vsx_posix/files/test_sets/scen.exec -j -";
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];
Expand All @@ -27,7 +27,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;
Expand All @@ -42,17 +42,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) {
perror("fopen");
single_test_f = open("/usr/test/lsb_vsx_posix/files/test_sets/scen_single.exec", O_WRONLY | O_CREAT | O_TRUNC, S_IFREG);
if (single_test_f == -1) {
perror("open");
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) {
Expand All @@ -61,15 +61,16 @@ 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[39] = '\0';
}
if (strstr(line, argv[1]) != NULL) {
/* Write second line */
write(single_test_f, total, strlen(total));
/* 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);
Expand Down Expand Up @@ -101,4 +102,4 @@ int main(int argc, char **argv)
return 1;
}
}
}
}
36 changes: 13 additions & 23 deletions lsb_vsx_posix/lsb_vsx_posix.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
#
# Phoenix-RTOS test runner
#
# The harness for the LSB_VSX-2.0-1 (POSIX) Test Suite
#
# Copyright 2022 Phoenix Systems
# Authors: Adam Dębek
#

from trunner.ctx import TestContext
from trunner.dut import Dut
from trunner.types import TestResult, Result, Status


def harness(dut: Dut):
def harness(dut: Dut, ctx: TestContext):
test_results = []
result = None
msg = []
test_name = []
test_status = Status.OK

NAME = r'(.+?)Execute(.+?)T\.(?P<name>.+?)\r+\n'
PROMPT = r'(\r+)\x1b\[0J' + r'\(psh\)% '
#RESULT = r"(.+?)(?P<status>PASS|UNRESOLVED|FAIL)\r+\n" no status unresolved for now
# RESULT = r"(.+?)(?P<status>PASS|UNRESOLVED|FAIL)\r+\n" no status unresolved for now
RESULT = r"(.+?)(?P<status>PASS|FAIL)\r+\n"
FINAL = r"(.+?)TCC End\r+\n"
MESSAGE = r"(?P<line>.*?)\r+\n"
Expand All @@ -35,7 +26,7 @@ def harness(dut: Dut):
MESSAGE
], timeout=300)
parsed = dut.match.groupdict()

if idx == 0:
test_name = parsed["name"]
elif idx == 1:
Expand All @@ -44,22 +35,22 @@ def harness(dut: Dut):
break
elif idx == 3:
line = parsed["line"]
#Get rid of unnecessary messages
if(line.find("IC") != -1 or line.find("TP") != -1 or line.find("TC") != -1 or line.find("Execute") != -1):
# Get rid of unnecessary messages
if (line.find("IC") != -1 or line.find("TP") != -1 or line.find("TC") != -1 or line.find("Execute") != -1):
continue
else:
line = line[line.find("|") + 1:]
line = line[line.find("|") + 1:]
msg.append('\t\t' + line + '\n')
#Tests with these problems treat as fails
# Tests with these problems treat as fails
if (line.find("can't acquire exclusive lock") != -1) or (line.find("can't exec") != -1):
test_status = Status.FAIL
result = Result(name=test_name, status=Status.FAIL)
result.status = Status.FAIL

if (line.find("can't acquire exclusive lock") != -1):
if (line.find("can't acquire exclusive lock") != -1):
result.msg = '\t\t' + "can't acquire exclusive lock\n"
elif(line.find("can't exec") != -1):
elif (line.find("can't exec") != -1):
result.msg = '\t\t' + "compilation error\n"

test_results.append(result)
Expand All @@ -71,12 +62,11 @@ def harness(dut: Dut):
test_status = Status.FAIL
result.msg = "\n".join(msg)
msg = []
#UNRESOLVED status not added yet
#elif msg and result.status == Status.UNRESOLVED:
# UNRESOLVED status not added yet
# elif msg and result.status == Status.UNRESOLVED:
# result.status = Status.UNRESOLVED

test_results.append(result)
result = None


return TestResult(msg=Result.format_output(test_results), status=test_status)
return TestResult(msg=Result.format_output(test_results, ctx), status=test_status)
34 changes: 0 additions & 34 deletions trunner/harnesses/factory.py

This file was deleted.

0 comments on commit 2483a3a

Please sign in to comment.