Skip to content

Commit

Permalink
lsb-vsx: add harness
Browse files Browse the repository at this point in the history
JIRA: CI-139
  • Loading branch information
adamdebek committed Sep 23, 2022
1 parent bc0ac5e commit 1241441
Show file tree
Hide file tree
Showing 6 changed files with 520 additions and 12 deletions.
File renamed without changes.
28 changes: 18 additions & 10 deletions lsb_vsx/lsb_vsx_posix.c → lsb_vsx_posix/lsb_vsx_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.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";
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";
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];
size_t len = 0;
ssize_t nread;
FILE *single_test_f;
int single_test_f;
FILE *all_tests_f;


Expand All @@ -39,12 +42,12 @@ 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 == NULL) {
if (all_tests_f == -1) {
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);
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");
exit(EXIT_FAILURE);
Expand All @@ -67,24 +70,29 @@ int main(int argc, char **argv)
write(single_test_f, line, nread);

/*Test found, everything we need written, so close and clean */
close(all_tests_f);
fclose(all_tests_f);
close(single_test_f);
free(line);
break;
}
}
if (nread == -1) {
fprintf(stderr,"No such test");
fprintf(stderr,"No such test\n");
return -1;
}

if ((system(cmd_single_test)) < 0) {
perror("system function failed:");
return 1;
}
}

if ((system(cmd_clean)) < 0) {
perror("system function failed:");
return 1;
}
}
else if (argc > 2) {
fprintf(stderr, "Type single test name or nothing to execute all tests");
fprintf(stderr, "Type single test name or nothing to execute all tests\n");
return -1;
}
else {
Expand Down
Loading

0 comments on commit 1241441

Please sign in to comment.