Skip to content

Commit d82ec2b

Browse files
authored
Merge pull request #56 from rcitach/rt-test
add rt-test
2 parents d65c5c1 + 0343118 commit d82ec2b

8 files changed

Lines changed: 346 additions & 0 deletions

File tree

apps/rt-tests/xmake.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2022-2023 RT-Thread Development Team
14+
--
15+
-- @author xqyjlj
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-06-21 xqyjlj initial version
22+
--
23+
24+
add_rules("mode.debug", "mode.release")
25+
26+
add_requires("rt-tests")
27+
28+
target("rt-tests")
29+
do
30+
set_kind("phony")
31+
add_packages("rt-tests")
32+
end
33+
target_end()
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
diff --git a/Makefile b/Makefile
2+
index 5110357..569adc1 100644
3+
--- a/Makefile
4+
+++ b/Makefile
5+
@@ -172,6 +172,7 @@ install: all install_hwlatdetect
6+
gzip -c src/cyclictest/cyclictest.8 >"$(DESTDIR)$(mandir)/man8/cyclictest.8.gz"
7+
gzip -c src/pi_tests/pi_stress.8 >"$(DESTDIR)$(mandir)/man8/pi_stress.8.gz"
8+
gzip -c src/ptsematest/ptsematest.8 >"$(DESTDIR)$(mandir)/man8/ptsematest.8.gz"
9+
+ gzip -c src/rt-migrate-test/rt-migrate-test.8 >"$(DESTDIR)$(mandir)/man8/rt-migrate-test.8.gz"
10+
gzip -c src/sigwaittest/sigwaittest.8 >"$(DESTDIR)$(mandir)/man8/sigwaittest.8.gz"
11+
gzip -c src/svsematest/svsematest.8 >"$(DESTDIR)$(mandir)/man8/svsematest.8.gz"
12+
gzip -c src/pmqtest/pmqtest.8 >"$(DESTDIR)$(mandir)/man8/pmqtest.8.gz"
13+
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
14+
index 00e5f3d..3f1bef1 100644
15+
--- a/src/cyclictest/cyclictest.c
16+
+++ b/src/cyclictest/cyclictest.c
17+
@@ -927,10 +927,14 @@ static int has_smi_counter(void)
18+
case 0x56: /* BDX-DE */
19+
case 0x4E: /* SKL */
20+
case 0x5E: /* SKL */
21+
+ case 0x8E: /* KBL */
22+
+ case 0x9E: /* KBL */
23+
+ case 0x55: /* SKX */
24+
case 0x37: /* BYT */
25+
case 0x4D: /* AVN */
26+
case 0x4C: /* AMT */
27+
case 0x57: /* PHI */
28+
+ case 0x5C: /* BXT */
29+
break;
30+
default:
31+
return 0;
32+
@@ -1684,7 +1688,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
33+
case 'R':
34+
case OPT_RESOLUTION:
35+
check_clock_resolution = 1; break;
36+
- case 's':
37+
case OPT_SECALIGNED:
38+
secaligned = 1;
39+
if (optarg != NULL)
40+
@@ -1694,6 +1697,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
41+
else
42+
offset = 0;
43+
break;
44+
+ case 's':
45+
case OPT_SYSTEM:
46+
use_system = MODE_SYS_OFFSET; break;
47+
case 'S':
48+
diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
49+
index d7b68dd..0a0bb77 100644
50+
--- a/src/rt-migrate-test/rt-migrate-test.c
51+
+++ b/src/rt-migrate-test/rt-migrate-test.c
52+
@@ -20,9 +20,6 @@
53+
*
54+
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
*/
56+
-#ifndef _GNU_SOURCE
57+
-#define _GNU_SOURCE
58+
-#endif
59+
#include <stdio.h>
60+
#ifndef __USE_XOPEN2K
61+
# define __USE_XOPEN2K
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
2+
index 3f1bef1..dc33eca 100644
3+
--- a/src/cyclictest/cyclictest.c
4+
+++ b/src/cyclictest/cyclictest.c
5+
@@ -25,7 +25,6 @@
6+
#include <time.h>
7+
#include <errno.h>
8+
#include <limits.h>
9+
-#include <linux/unistd.h>
10+
11+
#include <sys/prctl.h>
12+
#include <sys/stat.h>
13+
@@ -56,7 +55,7 @@
14+
15+
/* Ugly, but .... */
16+
#define gettid() syscall(__NR_gettid)
17+
-#define sigev_notify_thread_id _sigev_un._tid
18+
+#define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id
19+
20+
#ifdef __UCLIBC__
21+
#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
22+
@@ -1009,18 +1008,18 @@ static void *timerthread(void *param)
23+
sigprocmask(SIG_BLOCK, &sigset, NULL);
24+
25+
if (par->mode == MODE_CYCLIC) {
26+
- sigev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL;
27+
+ sigev.sigev_notify = 4 | SIGEV_SIGNAL;
28+
sigev.sigev_signo = par->signal;
29+
- sigev.sigev_notify_thread_id = stat->tid;
30+
+ // sigev.sigev_notify_thread_id = stat->tid;
31+
timer_create(par->clock, &sigev, &timer);
32+
tspec.it_interval = interval;
33+
}
34+
35+
memset(&schedp, 0, sizeof(schedp));
36+
schedp.sched_priority = par->prio;
37+
- if (setscheduler(0, par->policy, &schedp))
38+
- fatal("timerthread%d: failed to set priority to %d\n",
39+
- par->cpu, par->prio);
40+
+ if (setscheduler(0, par->policy, &schedp))
41+
+ fatal("timerthread%d: failed to set priority to %d\n",
42+
+ par->cpu, par->prio);
43+
44+
if(smi) {
45+
par->msr_fd = open_msr_file(par->cpu);
46+
@@ -1257,7 +1256,7 @@ out:
47+
close(par->msr_fd);
48+
/* switch to normal */
49+
schedp.sched_priority = 0;
50+
- sched_setscheduler(0, SCHED_OTHER, &schedp);
51+
+ // sched_setscheduler(0, SCHED_OTHER, &schedp);
52+
stat->threadstarted = -1;
53+
54+
return NULL;
55+
@@ -2195,8 +2194,8 @@ int main(int argc, char **argv)
56+
57+
process_options(argc, argv, max_cpus);
58+
59+
- if (check_privs())
60+
- exit(EXIT_FAILURE);
61+
+ // if (check_privs())
62+
+ // exit(EXIT_FAILURE);
63+
64+
if (verbose)
65+
printf("Max CPUs = %d\n", max_cpus);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/Makefile b/Makefile
2+
index 569adc1..3fae87e 100644
3+
--- a/Makefile
4+
+++ b/Makefile
5+
@@ -98,7 +98,7 @@ $(OBJDIR):
6+
mkdir $(OBJDIR)
7+
8+
# Include dependency files, automatically generate them if needed.
9+
--include $(addprefix $(OBJDIR)/,$(sources:.c=.d))
10+
+# -include $(addprefix $(OBJDIR)/,$(sources:.c=.d))
11+
12+
cyclictest: $(OBJDIR)/cyclictest.o $(OBJDIR)/librttest.a
13+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(RTTESTLIB) $(NUMA_LIBS)
14+
@@ -162,7 +162,7 @@ rebuild:
15+
$(MAKE) all
16+
17+
.PHONY: install
18+
-install: all install_hwlatdetect
19+
+install: install_hwlatdetect
20+
mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(mandir)/man4"
21+
mkdir -p "$(DESTDIR)$(srcdir)" "$(DESTDIR)$(mandir)/man8"
22+
cp $(TARGETS) "$(DESTDIR)$(bindir)"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
2+
index dc33eca..1129c87 100644
3+
--- a/src/cyclictest/cyclictest.c
4+
+++ b/src/cyclictest/cyclictest.c
5+
@@ -154,8 +154,8 @@ struct thread_param {
6+
7+
/* Struct for statistics */
8+
struct thread_stat {
9+
- unsigned long cycles;
10+
- unsigned long cyclesread;
11+
+ long cycles;
12+
+ long cyclesread;
13+
long min;
14+
long max;
15+
long act;
16+
@@ -172,7 +172,7 @@ struct thread_stat {
17+
long cycleofmax;
18+
long hist_overflow;
19+
long num_outliers;
20+
- unsigned long smi_count;
21+
+ long smi_count;
22+
};
23+
24+
static pthread_mutex_t trigger_lock = PTHREAD_MUTEX_INITIALIZER;
25+
@@ -1088,7 +1088,7 @@ static void *timerthread(void *param)
26+
27+
while (!shutdown) {
28+
29+
- uint64_t diff;
30+
+ int64_t diff;
31+
unsigned long diff_smi = 0;
32+
int sigs, ret;
33+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
2+
index 1129c87..a648246 100644
3+
--- a/src/cyclictest/cyclictest.c
4+
+++ b/src/cyclictest/cyclictest.c
5+
@@ -1917,7 +1917,7 @@ static int check_timer(void)
6+
if (clock_getres(CLOCK_MONOTONIC, &ts))
7+
return 1;
8+
9+
- return (ts.tv_sec != 0 || ts.tv_nsec != 1);
10+
+ return (ts.tv_sec != 0 || ts.tv_nsec == 0);
11+
}
12+
13+
static void sighand(int sig)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2023-2023 RT-Thread Development Team
14+
--
15+
-- @author xqyjlj
16+
-- @file deploy.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-05-11 xqyjlj initial version
22+
--
23+
import("rt.rt_utils")
24+
25+
function main(rootfs, installdir)
26+
for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do
27+
local filename = path.filename(filepath)
28+
rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename))
29+
end
30+
31+
for _, filepath in ipairs(os.files(path.join(installdir, "sbin") .. "/*")) do
32+
local filename = path.filename(filepath)
33+
rt_utils.cp_with_symlink(filepath, path.join(rootfs, "sbin", filename))
34+
end
35+
end

repo/packages/r/rt-tests/xmake.lua

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2023-2023 RT-Thread Development Team
14+
--
15+
-- @author xqyjlj
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-04-17 xqyjlj initial version
22+
--
23+
package("rt-tests")
24+
do
25+
set_homepage("https://wiki.linuxfoundation.org/realtime/documentation/howto/tools/rt-tests")
26+
set_description("suite of real-time tests")
27+
28+
add_urls("https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git/snapshot/rt-tests-$(version).tar.gz")
29+
30+
add_versions("1.0", "c543672cdeeb9033284b55ea64a7c7c7c385949646332dfbdd295cbedbf610b8")
31+
32+
add_patches("1.0", path.join(os.scriptdir(), "patches", "1.0", "01_stable_v1.0.diff"),
33+
"45068026d52fb21a3ed205255f3da563e64a4ebacca8cb692612b3769bfafc0c")
34+
add_patches("1.0", path.join(os.scriptdir(), "patches", "1.0", "02_cyclictest_c.diff"),
35+
"5bac2ea74f34bd986ab69a1ef8c4a0f3df99c166369bcb919e98b8a830742b59")
36+
add_patches("1.0", path.join(os.scriptdir(), "patches", "1.0", "03_Makefile.diff"),
37+
"1ecdb0083170492118da7d98fb2cbebde80d3e1f9f92f0fcb5e577cdf1f03c47")
38+
add_patches("1.0", path.join(os.scriptdir(), "patches", "1.0", "04_cyclictest_signed.diff"),
39+
"70c5730323fe17219b5953e0c7fb6ed6de0c306fd4e1efabc39ca3dd6ed01780")
40+
add_patches("1.0", path.join(os.scriptdir(), "patches", "1.0", "05_fix_high_resolution_timers_check.diff"),
41+
"deae130cd138ce85f3554821754c36bc624105224045e6c85231cde92163a026")
42+
43+
add_configs("shared", {
44+
description = "Build shared library.",
45+
default = os.getenv("RT_XMAKE_LINK_TYPE") ~= "static",
46+
type = "boolean"
47+
})
48+
add_configs("cyclictest", {description = "high resolution test program", default = true, type = "boolean"})
49+
50+
on_install("cross@linux", function(package)
51+
import("rt.private.build.rtflags")
52+
local info = rtflags.get_package_info(package)
53+
local host = info.host
54+
local cc = info.cc
55+
local ldflags = {}
56+
local configs = {}
57+
os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH"))
58+
59+
if info.arch == "x86_64" then
60+
table.insert(configs, "NUMA=0")
61+
end
62+
local buildenvs = import("package.tools.autoconf").buildenvs(package, {ldflags = ldflags})
63+
buildenvs["prefix"] = package:installdir()
64+
if package:config("cyclictest") then
65+
table.insert(configs, "cyclictest")
66+
end
67+
if package:config("debug") then
68+
table.insert(configs, "DEBUG=1")
69+
end
70+
71+
import("package.tools.make").build(package, configs, {envs = buildenvs})
72+
73+
if package:config("cyclictest") then
74+
os.vcp("cyclictest", package:installdir("bin"))
75+
os.vcp("src/cyclictest/cyclictest.8", package:installdir("share/man"))
76+
end
77+
end)
78+
79+
on_test(function(package)
80+
if package:config("cyclictest") then
81+
assert(os.isfile(path.join(package:installdir("bin"), "cyclictest")))
82+
end
83+
end)
84+
end

0 commit comments

Comments
 (0)