Skip to content

Commit

Permalink
sadd fs_mark harness
Browse files Browse the repository at this point in the history
JIRA: CI-307
  • Loading branch information
adamdebek committed Sep 4, 2023
1 parent 34e68b3 commit 9acbc20
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs_mark/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(eval $(call add_test, fs_mark_clean))
87 changes: 87 additions & 0 deletions fs_mark/fs_mark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import trunner
import timing_data as t_data

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


def harness(dut: Dut, ctx: TestContext):
subresults = []
test_name = None
test_status = Status.OK
f_use = None
count = None
size = None
files_sec = None
app_overhead = None
subresult = None
got_time = False
target = trunner.ctx.target.name

NAME = r"(.+?)/bin/(?P<name>fs_mark.+?)\r+\n"
MSG_LINE = r"(\s+)(?P<line>([\d\.]+\s*){23})\r+\n"
FINAL = r"(?P<final>Insufficient free space.+?)\r+\n"
END = r"(?P<end>Average Files/sec:.+?)\r+\n"

while True:
idx = dut.expect([
NAME,
MSG_LINE,
FINAL,
END
], timeout=50)
parsed = dut.match.groupdict()

if idx == 0:
test_name = parsed["name"]
elif idx == 1:
got_time = True
splited_line = parsed["line"].split()
f_use = splited_line[0]
count = splited_line[1]
size = splited_line[2]
files_sec = splited_line[3]
app_overhead = splited_line[4]

dict = {}
dict['creatMin'] = splited_line[5]
dict['creatAvg'] = splited_line[6]
dict['creatMax'] = splited_line[7]
dict['writeMin'] = splited_line[8]
dict['writeAvg'] = splited_line[9]
dict['writeMax'] = splited_line[10]
dict['closeMin'] = splited_line[17]
dict['closeAvg'] = splited_line[18]
dict['closeMax'] = splited_line[19]

subresult = TestSubResult(name=str(test_name), status=Status.OK)

for name, value in dict.items():
if not t_data.timing_dict[(target, name)][0] <= int(value) <= t_data.timing_dict[(target, name)][1]:
test_status = Status.FAIL
subresult.status = Status.FAIL
subresult.msg += "\n\t" + name + " exec time - " + value + \
" out of range [" + str(t_data.timing_dict[(target, name)][0]) + \

Check failure on line 65 in fs_mark/fs_mark.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E127 continuation line over-indented for visual indent

Check failure on line 65 in fs_mark/fs_mark.py

View workflow job for this annotation

GitHub Actions / build (3.10)

E127 continuation line over-indented for visual indent

Check failure on line 65 in fs_mark/fs_mark.py

View workflow job for this annotation

GitHub Actions / build (3.11)

E127 continuation line over-indented for visual indent
" - " + str(t_data.timing_dict[(target, name)][1]) + "]"

if subresult.status == Status.FAIL:
subresult.msg += "\n\n\tF_Use%: " + str(f_use)
subresult.msg += "\n\tCount: " + str(count)
subresult.msg += "\n\tSize: " + str(size)
subresult.msg += "\n\tFiles/sec: " + str(files_sec)
subresult.msg += "\n\tApp overhead: " + str(app_overhead) + "\n\t"

if subresult.status == Status.FAIL:
subresults.append(subresult)
break

elif idx == 2 or idx == 3:
if got_time is False:
subresult = TestSubResult(name=str(test_name), status=Status.FAIL)
subresult.msg += "\n\tGot no timings"

subresults.append(subresult)
break

return TestResult(status=test_status)

Check warning on line 87 in fs_mark/fs_mark.py

View workflow job for this annotation

GitHub Actions / build (3.9)

W292 no newline at end of file

Check warning on line 87 in fs_mark/fs_mark.py

View workflow job for this annotation

GitHub Actions / build (3.10)

W292 no newline at end of file

Check warning on line 87 in fs_mark/fs_mark.py

View workflow job for this annotation

GitHub Actions / build (3.11)

W292 no newline at end of file
68 changes: 68 additions & 0 deletions fs_mark/fs_mark_clean.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Phoenix-RTOS
*
* Runs fs_mark program and does clean up right after.
*
* Copyright 2023 Phoenix Systems
* Author: Adam Debek
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include <stdint.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <limits.h>

int remove_dir_recursive(const char *const dirPath)
{
DIR *const dir = opendir(dirPath);
struct dirent *entry;
char filename[PATH_MAX];
int (*remove_func)(const char *);

if (dir) {
while ((entry = readdir(dir))) {
if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name)) {
continue;
}

sprintf(filename, "%s/%s", dirPath, entry->d_name);
remove_func = entry->d_type == dtDir ? remove_dir_recursive : remove;
if (remove_func(entry->d_name)) {
closedir(dir);
return -1;
}
}
if (closedir(dir)) {
return -1;
}
}
return remove(dirPath);
}

int main(int argc, char **argv)
{
// int i;
// DIR *dir;

// for (i = 1; i < argc; i++) {
// if (dir = opendir(argv[i]) == NULL) {
// fprintf(stderr, "Nonexistent directory name\n");
// return 1;
// }
// /* Clean test directory */
// if (remove_dir_recursive(argv[i]) < 0) {
// fprintf(stderr, "Error in remove_dir_recursive()\n");
// return 1;
// }
// }

return 0;
}
13 changes: 13 additions & 0 deletions fs_mark/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test:
type: harness
harness: fs_mark.py
targets:
value: [ia32-generic-qemu, armv7a7-imx6ull-evk, armv7a9-zynq7000-qemu, armv7a9-zynq7000-zedboard]

tests:
- name: test1
execute: fs_mark -d /tmp/1 -s 1000 -n 500 -v -k
- name: test2
execute: fs_mark -d /tmp/2 -s 10000 -n 500 -v -k
- name: test3
execute: fs_mark -d /tmp/3 -s 100 -n 500 -v
40 changes: 40 additions & 0 deletions fs_mark/timing_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Timing ranges used in fs_mark harness

timing_dict = {
('ia32-generic-qemu', 'creatMin'): (0, 90000),
('ia32-generic-qemu', 'creatAvg'): (0, 90000),
('ia32-generic-qemu', 'creatMax'): (0, 90000),
('ia32-generic-qemu', 'writeMin'): (0, 90000),
('ia32-generic-qemu', 'writeAvg'): (0, 90000),
('ia32-generic-qemu', 'writeMax'): (0, 90000),
('ia32-generic-qemu', 'closeMin'): (0, 90000),
('ia32-generic-qemu', 'closeAvg'): (0, 90000),
('ia32-generic-qemu', 'closeMax'): (0, 90000),
('armv7a9-zynq7000-zedboard', 'creatMin'): (2000, 5000),
('armv7a9-zynq7000-zedboard', 'creatAvg'): (2000, 5000),
('armv7a9-zynq7000-zedboard', 'creatMax'): (0, 0),
('armv7a9-zynq7000-zedboard', 'writeMin'): (0, 0),
('armv7a9-zynq7000-zedboard', 'writeAvg'): (0, 0),
('armv7a9-zynq7000-zedboard', 'writeMax'): (0, 0),
('armv7a9-zynq7000-zedboard', 'closeMin'): (0, 0),
('armv7a9-zynq7000-zedboard', 'closeAvg'): (0, 0),
('armv7a9-zynq7000-zedboard', 'closeMax'): (0, 0),
('armv7a9-zynq7000-qemu', 'creatMin'): (0, 0),
('armv7a9-zynq7000-qemu', 'creatAvg'): (0, 0),
('armv7a9-zynq7000-qemu', 'creatMax'): (0, 0),
('armv7a9-zynq7000-qemu', 'writeMin'): (0, 0),
('armv7a9-zynq7000-qemu', 'writeAvg'): (0, 0),
('armv7a9-zynq7000-qemu', 'writeMax'): (0, 0),
('armv7a9-zynq7000-qemu', 'closeMin'): (0, 0),
('armv7a9-zynq7000-qemu', 'closeAvg'): (0, 0),
('armv7a9-zynq7000-qemu', 'closeMax'): (0, 0),
('armv7a7-imx6ull-evk', 'creatMin'): (500, 5000),
('armv7a7-imx6ull-evk', 'creatAvg'): (500, 5000),
('armv7a7-imx6ull-evk', 'creatMax'): (500, 7000),
('armv7a7-imx6ull-evk', 'writeMin'): (500, 20000),
('armv7a7-imx6ull-evk', 'writeAvg'): (500, 30000),
('armv7a7-imx6ull-evk', 'writeMax'): (500, 40000),
('armv7a7-imx6ull-evk', 'closeMin'): (30, 500),
('armv7a7-imx6ull-evk', 'closeAvg'): (30, 500),
('armv7a7-imx6ull-evk', 'closeMax'): (30, 500)
}

0 comments on commit 9acbc20

Please sign in to comment.