-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIRA: CI-307
- Loading branch information
Showing
15 changed files
with
1,337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$(eval $(call add_test, fs_mark_clean)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from trunner.ctx import TestContext | ||
from trunner.dut import Dut | ||
from trunner.types import TestResult, TestSubResult, Status | ||
import psh.tools.psh as psh | ||
|
||
|
||
def harness(dut: Dut, ctx: TestContext, result: TestResult): | ||
PROMPT = r'(\r*)\x1b\[0J' + r'\(psh\)% ' | ||
psh._send(pexpect_proc=dut, cmd='ls') | ||
dut.expect(PROMPT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import trunner | ||
import time | ||
import os | ||
import yaml | ||
import pexpect | ||
import timing_data as t_data | ||
import psh.tools.psh as psh | ||
|
||
from datetime import datetime | ||
from trunner.ctx import TestContext | ||
from trunner.dut import Dut | ||
from trunner.types import TestResult, TestSubResult, Status | ||
|
||
dummy_list = ['armv7m7-imxrt105x-evk', 'armv7m7-imxrt106x-evk', | ||
'armv7m7-imxrt117x-evk', 'armv7m4-stm32l4x6-nucleo'] | ||
|
||
def clean(dut, test_name): | ||
global dirs | ||
|
||
if trunner.ctx.target.name in dummy_list: | ||
return | ||
|
||
if '-k' in test_name or '-L' in test_name or '-F' in test_name: | ||
args = test_name.split() | ||
args = args[1:] | ||
|
||
def get_dir(x): | ||
if args[x[0] - 1] == '-d': | ||
return x[1] | ||
|
||
dirs = list(map(lambda x: get_dir(x), enumerate(args))) | ||
dirs = [x for x in dirs if x is not None] | ||
|
||
psh._send(dut, f'/bin/fs_mark_clean {" ".join(dirs)}') | ||
|
||
|
||
def harness(dut: Dut, ctx: TestContext, result: TestResult): | ||
target = trunner.ctx.target.name | ||
logs_path = '~/remote/logs/fs_mark_logs' | ||
test_status = Status.OK | ||
|
||
subresult = None | ||
test_name = None | ||
got_time = False | ||
first_loop = True | ||
|
||
f_use = None | ||
count = None | ||
size = None | ||
files_sec = None | ||
app_overhead = None | ||
|
||
start_time = None | ||
end_time = None | ||
loop_time = 600 | ||
|
||
NAME = r".+?# (?P<name>fs_mark.+?)\r+\n" | ||
MSG_LINE = r"(?P<line>(\s+\d+){3}.+?)\r+\n" | ||
FINAL = r"(?P<final>Insufficient free space.+?)\r+\n" | ||
END = r"(?P<end>Average Files/sec:.+?)\r+\n" | ||
END2 = r".+?(?P<end2>ENOMEM|EIO).+?" | ||
|
||
while True: | ||
if start_time and end_time: | ||
loop_time = 3 * (end_time - start_time) | ||
start_time = None | ||
end_time = None | ||
|
||
try: | ||
idx = dut.expect([ | ||
NAME, | ||
MSG_LINE, | ||
FINAL, | ||
END, | ||
END2 | ||
], timeout=loop_time) | ||
parsed = dut.match.groupdict() | ||
|
||
except pexpect.TIMEOUT: | ||
test_status = Status.FAIL | ||
subresult = TestSubResult(name=str(test_name), msg='Timeout, probably fs hang-up', status=Status.FAIL) | ||
result.add_subresult_obj(subresult) | ||
clean(dut, test_name) | ||
break | ||
|
||
if idx == 0: | ||
test_name = parsed["name"] | ||
start_time = time.time() | ||
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] | ||
|
||
try: | ||
with open(os.path.expanduser(logs_path), 'a') as file: | ||
if first_loop is True: | ||
first_loop = False | ||
file.write(test_name + ' ' + str(datetime.now()) + '\n') | ||
else: | ||
file.write('\n') | ||
yaml.dump(dict, file) | ||
|
||
except FileNotFoundError: | ||
print(f'Logs filepath: {logs_path} does not exist') | ||
|
||
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]) + \ | ||
" - " + 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: | ||
result.add_subresult_obj(subresult) | ||
subresult = None | ||
break | ||
|
||
elif idx == 3: | ||
end_time = time.time() | ||
if got_time is False: | ||
subresult = TestSubResult(name=str(test_name), status=Status.FAIL) | ||
subresult.msg += "\n\tGot no timings" | ||
|
||
result.add_subresult_obj(subresult) | ||
subresult = None | ||
clean(dut, test_name) | ||
break | ||
elif idx == 2: | ||
if got_time is False: | ||
subresult = TestSubResult(name=str(test_name), status=Status.FAIL) | ||
subresult.msg += "\n\tInsufficient free space" | ||
result.add_subresult_obj(subresult) | ||
subresult = None | ||
clean(dut, test_name) | ||
break | ||
elif idx == 4: | ||
if got_time is False: | ||
subresult = TestSubResult(name=str(test_name), status=Status.FAIL) | ||
subresult.msg += "\n\tENOMEM" | ||
result.add_subresult_obj(subresult) | ||
subresult = None | ||
clean(dut, test_name) | ||
break | ||
|
||
|
||
return TestResult(status=test_status) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* Cleanup after fs_mark (usage with keeping files). | ||
* | ||
* 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 *dirPath) | ||
{ | ||
DIR *dir = opendir(dirPath); | ||
struct dirent *entry; | ||
char filename[PATH_MAX]; | ||
int (*remove_func)(const char *); | ||
|
||
if (dir) { | ||
if (chdir(dirPath) < 0) { | ||
printf("chdir() failed, path: %s\n", dirPath); | ||
exit(1); | ||
} | ||
|
||
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(filename)) { | ||
closedir(dir); | ||
return -1; | ||
} | ||
if (chdir(dirPath) < 0) { | ||
printf("chdir() failed, path: %s\n", dirPath); | ||
exit(1); | ||
} | ||
} | ||
|
||
if (closedir(dir)) { | ||
return -1; | ||
} | ||
} | ||
|
||
return rmdir(dirPath); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int i; | ||
DIR *dir; | ||
|
||
if (argc < 2) { | ||
fprintf(stderr, "Usage: %s [dir1] ... [dirN]\n", argv[0]); | ||
return 1; | ||
} | ||
|
||
for (i = 1; i < argc; i++) { | ||
if ((dir = opendir(argv[i])) == NULL) { | ||
fprintf(stderr, "Nonexistent directory name\n"); | ||
return 1; | ||
} | ||
/* Clean test directory */ | ||
errno = 0; | ||
if (remove_dir_recursive(argv[i]) < 0) { | ||
fprintf(stderr, "Error in remove_dir_recursive() errno: %d\n", errno); | ||
return 1; | ||
} | ||
} | ||
|
||
fprintf(stderr, "Clean successful\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 0 -n 1 -v -k -S 0 | ||
- name: test2 | ||
execute: fs_mark -d /tmp/2 -s 5 -n 10 -v -k -S 0 | ||
- name: test3 | ||
execute: fs_mark -d /tmp/3 -s 100 -n 500 -v -k -S 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# This yaml contain armv7a7-imx6ull-evk specific fs_mark tests | ||
test: | ||
type: harness | ||
harness: fs_mark.py | ||
|
||
targets: | ||
value: [armv7a7-imx6ull-evk] | ||
|
||
# Each test is independent (target reboot) | ||
tests: | ||
# empty files | ||
- name: test1 | ||
execute: fs_mark -d /fs_mark_test -s 0 -n 100 -v -S 0 -F | ||
- name: test2 | ||
execute: fs_mark -d /fs_mark_test -D 4 -N 25 -s 0 -n 100 -v -S 0 -F | ||
- name: test3 | ||
execute: fs_mark -d /fs_mark_test -D 10 -N 10 -s 0 -n 100 -v -S 0 -F | ||
- name: test4 | ||
execute: fs_mark -d /fs_mark_test -D 100 -N 1 -s 0 -n 100 -v -S 0 -F | ||
# big file | ||
- name: test5 | ||
execute: fs_mark -d /fs_mark_test -s 300000 -w 1 -n 1 -v -S 0 | ||
- name: test6 | ||
execute: fs_mark -d /fs_mark_test -s 300000 -w 32 -n 1 -v -S 0 | ||
- name: test7 | ||
execute: fs_mark -d /fs_mark_test -s 300000 -w 256 -n 1 -v -S 0 | ||
- name: test8 | ||
execute: fs_mark -d /fs_mark_test -s 300000 -w 1000 -n 1 -v -S 0 | ||
# s=256 w=256 | ||
- name: test9 | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 256 -n 1 -v -S 0 -F | ||
- name: test10 | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 256 -n 10 -v -S 0 -F | ||
- name: test11 | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 256 -n 100 -v -S 0 -F | ||
- name: test12 | ||
execute: fs_mark -d /fs_mark_test -D 4 -N 25 -s 256 -w 256 -n 100 -v -S 0 -F | ||
- name: test13 | ||
execute: fs_mark -d /fs_mark_test -D 10 -N 10 -s 256 -w 256 -n 100 -v -S 0 -F | ||
- name: test14 | ||
execute: fs_mark -d /fs_mark_test -D 100 -N 1 -s 256 -w 256 -n 100 -v -S 0 -F | ||
# s=1024 w=256 | ||
- name: test15 | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 256 -n 1 -v -S 0 -F | ||
- name: test16 | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 256 -n 10 -v -S 0 -F | ||
- name: test17 | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 256 -n 100 -v -S 0 -F | ||
- name: test18 | ||
execute: fs_mark -d /fs_mark_test -D 4 -N 25 -s 1024 -w 256 -n 100 -v -S 0 -F | ||
- name: test19 | ||
execute: fs_mark -d /fs_mark_test -D 10 -N 10 -s 1024 -w 256 -n 100 -v -S 0 -F | ||
- name: test20 | ||
execute: fs_mark -d /fs_mark_test -D 100 -N 1 -s 1024 -w 256 -n 100 -v -S 0 -F | ||
# s=10000 w=256 | ||
- name: test21 | ||
execute: fs_mark -d /fs_mark_test -s 10000 -w 256 -n 1 -v -S 0 -F | ||
- name: test22 | ||
execute: fs_mark -d /fs_mark_test -s 10000 -w 256 -n 10 -v -S 0 -F | ||
- name: test23 | ||
execute: fs_mark -d /fs_mark_test -s 10000 -w 256 -n 100 -v -S 0 -F | ||
- name: test24 | ||
execute: fs_mark -d /fs_mark_test -D 4 -N 25 -s 10000 -w 256 -n 25 -v -S 0 -F | ||
- name: test25 | ||
execute: fs_mark -d /fs_mark_test -D 10 -N 10 -s 10000 -w 256 -n 25 -v -S 0 -F | ||
- name: test26 | ||
execute: fs_mark -d /fs_mark_test -D 100 -N 1 -s 10000 -w 256 -n 25 -v -S 0 -F | ||
# s=256 w=32 | ||
- name: test27 | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 32 -n 1 -v -S 0 -F | ||
- name: test28 | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 32 -n 10 -v -S 0 -F | ||
- name: test29 | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 32 -n 100 -v -S 0 -F | ||
- name: test30 | ||
execute: fs_mark -d /fs_mark_test -D 4 -N 25 -s 256 -w 32 -n 100 -v -S 0 -F | ||
- name: test31 | ||
execute: fs_mark -d /fs_mark_test -D 10 -N 10 -s 256 -w 32 -n 100 -v -S 0 -F | ||
- name: test32 | ||
execute: fs_mark -d /fs_mark_test -D 100 -N 1 -s 256 -w 32 -n 100 -v -S 0 -F | ||
# s=1024 w=32 | ||
- name: test33 | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 32 -n 1 -v -S 0 -F | ||
- name: test34 | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 32 -n 10 -v -S 0 -F | ||
- name: test35 | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 32 -n 100 -v -S 0 -F | ||
- name: test36 | ||
execute: fs_mark -d /fs_mark_test -D 4 -N 25 -s 1024 -w 32 -n 100 -v -S 0 -F | ||
- name: test37 | ||
execute: fs_mark -d /fs_mark_test -D 10 -N 10 -s 1024 -w 32 -n 100 -v -S 0 -F | ||
- name: test38 | ||
execute: fs_mark -d /fs_mark_test -D 100 -N 1 -s 1024 -w 32 -n 100 -v -S 0 -F | ||
# s=10000 w=32 | ||
- name: test39 | ||
execute: fs_mark -d /fs_mark_test -s 10000 -w 32 -n 1 -v -S 0 -F | ||
- name: test40 | ||
execute: fs_mark -d /fs_mark_test -s 10000 -w 32 -n 10 -v -S 0 -F | ||
- name: test41 | ||
execute: fs_mark -d /fs_mark_test -s 10000 -w 32 -n 25 -v -S 0 | ||
- name: test42 | ||
execute: fs_mark -d /fs_mark_test -D 4 -N 25 -s 10000 -w 32 -n 25 -v -S 0 | ||
- name: test43 | ||
execute: fs_mark -d /fs_mark_test -D 10 -N 10 -s 10000 -w 32 -n 25 -v -S 0 | ||
- name: test44 | ||
execute: fs_mark -d /fs_mark_test -D 100 -N 1 -s 10000 -w 32 -n 25 -v -S 0 |
Oops, something went wrong.