Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add posix tests (waiting for lsb_vsx port merge) #126

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lsb_vsx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME := run-test
LOCAL_SRCS := run-test.c

include $(binary.mk)
56 changes: 56 additions & 0 deletions lsb_vsx/lsb_vsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from typing import Optional

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


def harness(dut: Dut, ctx: TestContext, result: TestResult) -> Optional[TestResult]:
tc_start = r"(.+?\|){2}TP Start\r+\n"
tc_end = r"(.+?\|){2}IC End\r+\n"
results = r"(.+?\|){2}(?P<status>PASS|FAIL|UNRESOLVED|UNSUPPORTED|NOTINUSE|UNTESTED|UNINITIATED|NORESULT|INVALID RESULT)\r+\n" # noqa: E501
adamdebek marked this conversation as resolved.
Show resolved Hide resolved
final = r"(.+?\|){2}TC End.+?\r+\n"
msg_line = r"(.+?\|){2}(?P<msg_line>.+?)\r+\n"

stats = {"FAIL": 0, "IGNORE": 0, "PASS": 0, "UNTESTED": 0}
get_msg, msg = False, ""
tc_num = 0

dut.expect("Config End\r+\n")

while True:
idx = dut.expect([tc_start, results, tc_end, final, msg_line], timeout=2000)
parsed = dut.match.groupdict()

if idx == 0:
get_msg = True

elif idx == 1:
if parsed["status"] in ("UNSUPPORTED", "NOTINUSE"):
parsed["status"] = "IGNORE"
elif parsed["status"] in ("UNRESOLVED", "UNINITIATED", "NORESULT"):
# TODO: research pseudo-languages
if msg and "pseudo language" not in msg:
parsed["status"] = "FAIL"
else:
parsed["status"] = "IGNORE"
elif parsed["status"] in ("INVALID RESULT"):
parsed["status"] = "FAIL"

status = Status.from_str(parsed["status"])
stats[parsed["status"]] += 1

elif idx == 2:
tc_num += 1
subname = f"testcase {tc_num}"
result.add_subresult(subname, status, msg)
get_msg, msg = False, ""

elif idx == 3:
break

elif idx == 4 and get_msg:
msg += ("" if not msg else "\n") + parsed["msg_line"]

status = Status.FAIL if stats["FAIL"] != 0 else Status.OK
return TestResult(status=status)
68 changes: 68 additions & 0 deletions lsb_vsx/run-test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Phoenix-RTOS
*
* lsb_vsx test launcher
*
* Copyright 2024 Phoenix Systems
* Author: Adam Debek
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>


int main(int argc, char **argv)
{
const char *cmd = "/usr/bin/tcc -j - -e -l ";
adamdebek marked this conversation as resolved.
Show resolved Hide resolved
char test_cmd[128];
int ret;

if (argc != 2) {
fprintf(stderr, "Wrong number of arguments, provide only a path to test executable\n");
exit(EXIT_FAILURE);
}
else {
strcpy(test_cmd, cmd);
strcat(test_cmd, argv[1]);
}

if (chdir("/root/lsb_vsx/test_sets") < 0) {
perror("chdir");
exit(EXIT_FAILURE);
}

if (setenv("TET_ROOT", "/root/lsb_vsx", 0) < 0) {
fprintf(stderr, "setenv() - setting \"TET_ROOT\" failed\n");
exit(EXIT_FAILURE);
}

if (setenv("TET_EXECUTE", "/root/lsb_vsx/test_sets/TESTROOT", 0) < 0) {
fprintf(stderr, "setenv() - setting \"TET_EXECUTE\" failed\n");
exit(EXIT_FAILURE);
}

if ((ret = system(test_cmd)) < 0) {
perror("system");
exit(EXIT_FAILURE);
}

if (WIFEXITED(ret)) {
int exit_status = WEXITSTATUS(ret);
if (exit_status != 0) {
fprintf(stderr, "Error: Command exited with status %d\n", exit_status);
exit(EXIT_FAILURE);
}
}
else {
fprintf(stderr, "Error: Command did not exit normally\n");
exit(EXIT_FAILURE);
}

return EXIT_SUCCESS;
}
Loading
Loading