-
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
11 changed files
with
608 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,4 @@ | ||
NAME := fs_mark_clean | ||
LOCAL_SRCS := fs_mark_clean.c | ||
|
||
include $(binary.mk) |
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,54 @@ | ||
import re | ||
|
||
from typing import Optional | ||
|
||
import psh.tools.psh as psh | ||
|
||
from trunner.ctx import TestContext | ||
from trunner.dut import Dut | ||
from trunner.types import TestResult, Status | ||
|
||
from time_limits import time_limits | ||
|
||
|
||
def _fs_clean(dut, ctx): | ||
if any(opt in ctx.cmd for opt in ("-k", "-L", "-F")): | ||
dirs = re.findall(r"-d\s+([^\s]+)", ctx.cmd) | ||
psh.send_cmd(dut, f"fs_mark_clean {' '.join(dirs)}", exec_prefix=True) | ||
|
||
|
||
def harness(dut: Dut, ctx: TestContext) -> Optional[TestResult]: | ||
loop_line = r"(?P<line>(\s+\d+){3}.+?)\r+\n" | ||
end_msg = r"p99 Files/sec" | ||
error = r"fs_mark: (?P<err_msg>.+?)\r+\n" | ||
|
||
headers = ("FSUse%", "Count", "Size", "Files/sec", "App Overhead", | ||
"creatMin", "creatAvg", "creatMax", | ||
"writeMin", "writeAvg", "writeMax", | ||
"fsyncMin", "fsyncAvg", "fsyncMax", | ||
"syncMin", "syncAvg", "syncMax", | ||
"closeMin", "closeAvg", "closeMax", | ||
"unlinkMin", "unlinkAvg", "unlinkMax") | ||
|
||
limits = time_limits[ctx.target.name] | ||
|
||
while True: | ||
idx = dut.expect([loop_line, error, end_msg], 600) | ||
parsed = dut.match.groupdict() | ||
|
||
if idx == 0: | ||
figures = dict(zip(headers, parsed["line"].split())) | ||
for name, value in list(figures.items())[5:]: | ||
lower_bound = limits.get(name)[0] | ||
upper_bound = limits.get(name)[1] | ||
|
||
if not lower_bound <= int(value) <= upper_bound: | ||
msg = f"{name}: {value} not in range ({lower_bound},{upper_bound})" | ||
return TestResult(msg=msg, status=Status.FAIL) | ||
|
||
elif idx == 1: | ||
return TestResult(msg=parsed["err_msg"], status=Status.FAIL) | ||
|
||
elif idx == 2: | ||
_fs_clean(dut, ctx) | ||
return TestResult(status=Status.OK) |
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,116 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* Cleanup after fs_mark (used when files are kept). | ||
* | ||
* Copyright 2025 Phoenix Systems | ||
* Author: Adam Debek | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
#include <errno.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <dirent.h> | ||
#include <string.h> | ||
#include <limits.h> | ||
|
||
|
||
static int remove_dir_recursive(const char *dirPath) | ||
{ | ||
char entryPath[PATH_MAX]; | ||
DIR *dir; | ||
struct dirent *entry; | ||
|
||
if ((dir = opendir(dirPath)) == NULL) { | ||
perror("opendir"); | ||
return -1; | ||
} | ||
|
||
while ((entry = readdir(dir)) != NULL) { | ||
if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name)) { | ||
continue; | ||
} | ||
|
||
sprintf(entryPath, "%s/%s", dirPath, entry->d_name); | ||
|
||
if (entry->d_type == DT_DIR) { | ||
errno = 0; | ||
if (rmdir(entryPath) < 0) { | ||
if (errno == ENOTEMPTY) { | ||
if (remove_dir_recursive(entryPath) < 0) { | ||
closedir(dir); | ||
return -1; | ||
} | ||
} | ||
else { | ||
perror("rmdir"); | ||
closedir(dir); | ||
return -1; | ||
} | ||
} | ||
} | ||
else { | ||
if (unlink(entryPath) < 0) { | ||
perror("unlink"); | ||
closedir(dir); | ||
return -1; | ||
} | ||
} | ||
} | ||
|
||
if (closedir(dir) < 0) { | ||
perror("closedir"); | ||
return -1; | ||
} | ||
|
||
if (rmdir(dirPath)) { | ||
return -1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
||
int main(int argc, char **argv) | ||
{ | ||
DIR *dir; | ||
int ret; | ||
|
||
if (argc < 2) { | ||
fprintf(stderr, "Usage: %s [dir1] ... [dirN]\n", argv[0]); | ||
return 1; | ||
} | ||
|
||
for (int i = 1; i < argc; i++) { | ||
if ((dir = opendir(argv[i])) == NULL) { | ||
perror("opendir"); | ||
return 1; | ||
} | ||
|
||
/* Run remove_dir_recursive() multiple times because: | ||
Issue: https://github.com/phoenix-rtos/phoenix-rtos-project/issues/900 | ||
Issue: https://github.com/phoenix-rtos/phoenix-rtos-project/issues/1117 | ||
*/ | ||
for (int j = 0; j < 20; j++) { | ||
errno = 0; | ||
ret = remove_dir_recursive(argv[i]); | ||
if (ret == 0) { | ||
break; | ||
} | ||
else if (ret < 0 && errno == ENOTEMPTY) { | ||
continue; | ||
} | ||
else { | ||
fprintf(stderr, "Error in remove_dir_recursive() errno: %s\n", strerror(errno)); | ||
return 1; | ||
} | ||
} | ||
} | ||
|
||
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,9 @@ | ||
test: | ||
harness: fs_mark.py | ||
nightly: true | ||
targets: | ||
value: [armv7a7-imx6ull-evk] | ||
|
||
tests: | ||
- name: dummy (s=1000 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 1000 -n 1 -v |
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,9 @@ | ||
test: | ||
harness: fs_mark.py | ||
nightly: true | ||
targets: | ||
value: [armv7a9-zynq7000-qemu] | ||
|
||
tests: | ||
- name: dummy (s=1000 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 1000 -n 1 -v |
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,9 @@ | ||
test: | ||
harness: fs_mark.py | ||
nightly: true | ||
targets: | ||
value: [armv7a9-zynq7000-zedboard] | ||
|
||
tests: | ||
- name: dummy (s=1000 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 1000 -n 1 -v |
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,75 @@ | ||
test: | ||
harness: fs_mark.py | ||
nightly: true | ||
targets: | ||
value: [atmv7m4-stm32l4x6-nucleo] | ||
load: | ||
- app: fs_mark_clean | ||
exec: False | ||
|
||
tests: | ||
# empty files | ||
- name: empty_files (s=0 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=4 N=50 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 4 -N 50 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=10 N=20 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 10 -N 20 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=50 N=4 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 50 -N 4 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=100 N=2 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 100 -N 2 -n 200 -v | ||
|
||
# big file | ||
- name: big_file (s=150000 w=1 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 1 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=32 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 32 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=113 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 113 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=512 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 512 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=513 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 513 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=4096 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 4096 -n 1 -v | ||
|
||
# medium size | ||
- name: medium_size (s=32 w=32 n=1 L=200) | ||
execute: fs_mark -d /fs_mark_test -s 32 -w 32 -n 1 -L 200 -v | ||
|
||
- name: medium_size (s=70 w=64 D=4 N=4 n=1 L=50) | ||
execute: fs_mark -d /fs_mark_test -s 70 -w 64 -D 4 -N 4 -n 1 -L 50 -v | ||
|
||
- name: medium_size (s=256 w=65 D=10 N=10 n=1 L=20) | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 65 -D 10 -N 10 -n 1 -L 20 -v | ||
|
||
- name: medium_size (s=352 w=128 D=50 N=50 n=1 L=4) | ||
execute: fs_mark -d /fs_mark_test -s 352 -w 128 -D 50 -N 50 -n 1 -L 4 -v | ||
|
||
- name: medium_size (s=512 w=150 D=100 N=100 n=1 L=2) | ||
execute: fs_mark -d /fs_mark_test -s 512 -w 150 -D 100 -N 100 -n 1 -L 2 -v | ||
|
||
- name: medium_size (s=513 w=32 n=1 L=100) | ||
execute: fs_mark -d /fs_mark_test -s 513 -w 32 -n 1 -L 100 -v | ||
|
||
- name: medium_size (s=631 w=124 D=4 N=4 n=1 L=25) | ||
execute: fs_mark -d /fs_mark_test -s 631 -w 124 -D 4 -N 4 -n 1 -L 25 -v | ||
|
||
- name: medium_size (s=783 w=367 D=10 N=10 n=1 L=10) | ||
execute: fs_mark -d /fs_mark_test -s 783 -w 367 -D 10 -N 10 -n 1 -L 10 -v | ||
|
||
- name: medium_size (s=913 w=512 D=50 N=50 n=1 L=2) | ||
execute: fs_mark -d /fs_mark_test -s 913 -w 512 -D 50 -N 50 -n 1 -L 2 -v | ||
|
||
- name: medium_size (s=1024 w=127 D=100 N=100 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 127 -D 100 -N 100 -n 1 -v |
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,75 @@ | ||
test: | ||
harness: fs_mark.py | ||
nightly: true | ||
targets: | ||
value: [armv7m7-imxrt106x-evk] | ||
load: | ||
- app: fs_mark_clean | ||
exec: False | ||
|
||
tests: | ||
# empty files | ||
- name: empty_files (s=0 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=4 N=50 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 4 -N 50 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=10 N=20 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 10 -N 20 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=50 N=4 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 50 -N 4 -n 200 -v | ||
|
||
- name: empty_files (s=0 D=100 N=2 n=200) | ||
execute: fs_mark -d /fs_mark_test -s 0 -D 100 -N 2 -n 200 -v | ||
|
||
# big file | ||
- name: big_file (s=150000 w=1 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 1 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=32 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 32 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=113 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 113 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=512 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 512 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=513 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 513 -n 1 -v | ||
|
||
- name: big_file (s=150000 w=4096 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 150000 -w 4096 -n 1 -v | ||
|
||
# medium size | ||
- name: medium_size (s=32 w=32 n=1 L=200) | ||
execute: fs_mark -d /fs_mark_test -s 32 -w 32 -n 1 -L 200 -v | ||
|
||
- name: medium_size (s=70 w=64 D=4 N=4 n=1 L=50) | ||
execute: fs_mark -d /fs_mark_test -s 70 -w 64 -D 4 -N 4 -n 1 -L 50 -v | ||
|
||
- name: medium_size (s=256 w=65 D=10 N=10 n=1 L=20) | ||
execute: fs_mark -d /fs_mark_test -s 256 -w 65 -D 10 -N 10 -n 1 -L 20 -v | ||
|
||
- name: medium_size (s=352 w=128 D=50 N=50 n=1 L=4) | ||
execute: fs_mark -d /fs_mark_test -s 352 -w 128 -D 50 -N 50 -n 1 -L 4 -v | ||
|
||
- name: medium_size (s=512 w=150 D=100 N=100 n=1 L=2) | ||
execute: fs_mark -d /fs_mark_test -s 512 -w 150 -D 100 -N 100 -n 1 -L 2 -v | ||
|
||
- name: medium_size (s=513 w=32 n=1 L=100) | ||
execute: fs_mark -d /fs_mark_test -s 513 -w 32 -n 1 -L 100 -v | ||
|
||
- name: medium_size (s=631 w=124 D=4 N=4 n=1 L=25) | ||
execute: fs_mark -d /fs_mark_test -s 631 -w 124 -D 4 -N 4 -n 1 -L 25 -v | ||
|
||
- name: medium_size (s=783 w=367 D=10 N=10 n=1 L=10) | ||
execute: fs_mark -d /fs_mark_test -s 783 -w 367 -D 10 -N 10 -n 1 -L 10 -v | ||
|
||
- name: medium_size (s=913 w=512 D=50 N=50 n=1 L=2) | ||
execute: fs_mark -d /fs_mark_test -s 913 -w 512 -D 50 -N 50 -n 1 -L 2 -v | ||
|
||
- name: medium_size (s=1024 w=127 D=100 N=100 n=1) | ||
execute: fs_mark -d /fs_mark_test -s 1024 -w 127 -D 100 -N 100 -n 1 -v |
Oops, something went wrong.