Skip to content

Commit

Permalink
add rt-test
Browse files Browse the repository at this point in the history
  • Loading branch information
xqyjlj authored and rcitach committed Nov 5, 2024
1 parent 0b52ab7 commit 7902de9
Show file tree
Hide file tree
Showing 21 changed files with 394 additions and 144 deletions.
33 changes: 4 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# 介绍与快速入门

> 本文档环境为 `ubuntu 20.04`
>
> 更多文档请前往 https://club.rt-thread.org/ask/article/1c95a3e1c58c0c25.html
## 介绍

Expand Down Expand Up @@ -38,19 +36,7 @@ xmake 是一个基于 Lua 的轻量级跨平台构建工具,使用 xmake.lua
sudo apt install xmake
```

3. **安装 qemu**

userapps 已提供 qemu 7.1.0 的安装包,请自行下载 https://download-redirect.rt-thread.org/download/rt-smart/native/tools/qemu/qemu_7.1.0-2022111713_amd64.deb

```shell
sudo apt-get install -y libglib2.0-dev libpixman-1-dev
curl -L https://download-redirect.rt-thread.org/download/rt-smart/native/tools/qemu/qemu_7.1.0-2022111713_amd64.deb -o ./qemu.deb
sudo dpkg -i ./qemu.deb
```

如若想安装最新版本,请自行下载 qemu 源码进行编译安装

4. **编译**
3. **编译**

由于 smart 采用 xmake 编译用户态环境,因此 smart 的编译方式非常简单。

Expand All @@ -70,30 +56,19 @@ xmake 是一个基于 Lua 的轻量级跨平台构建工具,使用 xmake.lua

![image-20230531173059551](./assets/image-20230531173059551.png)

支持的平台:arm、aarch64、riscv64gc。

5. **镜像制作**

运行 `xmake smart-rootfs` 制作 rootfs ,运行 `xmake smart-image` 制作镜像

```shell
xmake smart-rootfs
xmake smart-image -o ../prebuilt/qemu-virt64-aarch64/ext4.img # 将镜像输出至 qemu-virt64-aarch64 目录
xmake smart-image -f ext4 #制作 ext4 镜像
```

![image-20230531173829621](./assets/image-20230531173829621.png)

6. **运行 qemu**

进入 `userapp/prebuilt/qemu-virt64-aarch64`,运行 qemu.sh 脚本启动 qemu

```shell
cd prebuilt/qemu-virt64-aarch64/
./run.sh
```

![image-20230531174321326](./assets/image-20230531174321326.png)

在 qemu 中 输入 `ctrl+a` 抬起后,再输入 `x` 即可退出 qemu

## prebuilt 的版本

会在每天凌晨生成 aarch64/riscv64 for qemu 的 prebuilt 版本,包括内核和 rootfs 文件系统:
Expand Down
33 changes: 33 additions & 0 deletions apps/rt-tests/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- Licensed under the Apache License, Version 2.0 (the "License");
-- You may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2022-2023 RT-Thread Development Team
--
-- @author xqyjlj
-- @file xmake.lua
--
-- Change Logs:
-- Date Author Notes
-- ------------ ---------- -----------------------------------------------
-- 2023-06-21 xqyjlj initial version
--

add_rules("mode.debug", "mode.release")

add_requires("rt-tests")

target("rt-tests")
do
set_kind("phony")
add_packages("rt-tests")
end
target_end()
Binary file removed assets/image-20230531174321326.png
Binary file not shown.
Binary file removed prebuilt/qemu-virt64-aarch64/ext4.img
Binary file not shown.
Binary file removed prebuilt/qemu-virt64-aarch64/rtthread.bin
Binary file not shown.
26 changes: 0 additions & 26 deletions prebuilt/qemu-virt64-aarch64/run.sh

This file was deleted.

28 changes: 0 additions & 28 deletions prebuilt/qemu-virt64-aarch64/run_debug.sh

This file was deleted.

Binary file removed prebuilt/qemu-virt64-riscv/ext4.img
Binary file not shown.
Binary file removed prebuilt/qemu-virt64-riscv/rtthread.bin
Binary file not shown.
25 changes: 0 additions & 25 deletions prebuilt/qemu-virt64-riscv/run.sh

This file was deleted.

27 changes: 0 additions & 27 deletions prebuilt/qemu-virt64-riscv/run_debug.sh

This file was deleted.

1 change: 0 additions & 1 deletion prebuilt/sha1sum.txt

This file was deleted.

4 changes: 2 additions & 2 deletions repo/packages/r/riscv64gc-unknown-smart-musl/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ do
if (version and sha256) then
add_versions(version, sha256)
else
add_versions("203957-8a397096c1", "0c4a43bc40ddee60774ce384d13760d235e51fd70658c5da0503caec1dd511e4")
add_versions("222725-8a397096c1", "488b1c8a5b82d94a57eff16c5ed705e91196eff4fda81ade9516da16241e007c")
end
elseif is_host("linux") then
add_urls(
Expand All @@ -45,7 +45,7 @@ do
if (version and sha256) then
add_versions(version, sha256)
else
add_versions("203957-8a397096c1", "19d9a73b1dff1d941953fcb673443259d89362c2e56d1d260af0cc503d9e9f5b")
add_versions("222725-8a397096c1", "6d4b67648f8471910323a0fe39d8d4a58153a5d81ea24362a8cf48d4f1894181")
end
end

Expand Down
61 changes: 61 additions & 0 deletions repo/packages/r/rt-tests/patches/1.0/01_stable_v1.0.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
diff --git a/Makefile b/Makefile
index 5110357..569adc1 100644
--- a/Makefile
+++ b/Makefile
@@ -172,6 +172,7 @@ install: all install_hwlatdetect
gzip -c src/cyclictest/cyclictest.8 >"$(DESTDIR)$(mandir)/man8/cyclictest.8.gz"
gzip -c src/pi_tests/pi_stress.8 >"$(DESTDIR)$(mandir)/man8/pi_stress.8.gz"
gzip -c src/ptsematest/ptsematest.8 >"$(DESTDIR)$(mandir)/man8/ptsematest.8.gz"
+ gzip -c src/rt-migrate-test/rt-migrate-test.8 >"$(DESTDIR)$(mandir)/man8/rt-migrate-test.8.gz"
gzip -c src/sigwaittest/sigwaittest.8 >"$(DESTDIR)$(mandir)/man8/sigwaittest.8.gz"
gzip -c src/svsematest/svsematest.8 >"$(DESTDIR)$(mandir)/man8/svsematest.8.gz"
gzip -c src/pmqtest/pmqtest.8 >"$(DESTDIR)$(mandir)/man8/pmqtest.8.gz"
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 00e5f3d..3f1bef1 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -927,10 +927,14 @@ static int has_smi_counter(void)
case 0x56: /* BDX-DE */
case 0x4E: /* SKL */
case 0x5E: /* SKL */
+ case 0x8E: /* KBL */
+ case 0x9E: /* KBL */
+ case 0x55: /* SKX */
case 0x37: /* BYT */
case 0x4D: /* AVN */
case 0x4C: /* AMT */
case 0x57: /* PHI */
+ case 0x5C: /* BXT */
break;
default:
return 0;
@@ -1684,7 +1688,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
case 'R':
case OPT_RESOLUTION:
check_clock_resolution = 1; break;
- case 's':
case OPT_SECALIGNED:
secaligned = 1;
if (optarg != NULL)
@@ -1694,6 +1697,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
else
offset = 0;
break;
+ case 's':
case OPT_SYSTEM:
use_system = MODE_SYS_OFFSET; break;
case 'S':
diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
index d7b68dd..0a0bb77 100644
--- a/src/rt-migrate-test/rt-migrate-test.c
+++ b/src/rt-migrate-test/rt-migrate-test.c
@@ -20,9 +20,6 @@
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
#include <stdio.h>
#ifndef __USE_XOPEN2K
# define __USE_XOPEN2K
65 changes: 65 additions & 0 deletions repo/packages/r/rt-tests/patches/1.0/02_cyclictest_c.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 3f1bef1..dc33eca 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -25,7 +25,6 @@
#include <time.h>
#include <errno.h>
#include <limits.h>
-#include <linux/unistd.h>

#include <sys/prctl.h>
#include <sys/stat.h>
@@ -56,7 +55,7 @@

/* Ugly, but .... */
#define gettid() syscall(__NR_gettid)
-#define sigev_notify_thread_id _sigev_un._tid
+#define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id

#ifdef __UCLIBC__
#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
@@ -1009,18 +1008,18 @@ static void *timerthread(void *param)
sigprocmask(SIG_BLOCK, &sigset, NULL);

if (par->mode == MODE_CYCLIC) {
- sigev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL;
+ sigev.sigev_notify = 4 | SIGEV_SIGNAL;
sigev.sigev_signo = par->signal;
- sigev.sigev_notify_thread_id = stat->tid;
+ // sigev.sigev_notify_thread_id = stat->tid;
timer_create(par->clock, &sigev, &timer);
tspec.it_interval = interval;
}

memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = par->prio;
- if (setscheduler(0, par->policy, &schedp))
- fatal("timerthread%d: failed to set priority to %d\n",
- par->cpu, par->prio);
+ if (setscheduler(0, par->policy, &schedp))
+ fatal("timerthread%d: failed to set priority to %d\n",
+ par->cpu, par->prio);

if(smi) {
par->msr_fd = open_msr_file(par->cpu);
@@ -1257,7 +1256,7 @@ out:
close(par->msr_fd);
/* switch to normal */
schedp.sched_priority = 0;
- sched_setscheduler(0, SCHED_OTHER, &schedp);
+ // sched_setscheduler(0, SCHED_OTHER, &schedp);
stat->threadstarted = -1;

return NULL;
@@ -2195,8 +2194,8 @@ int main(int argc, char **argv)

process_options(argc, argv, max_cpus);

- if (check_privs())
- exit(EXIT_FAILURE);
+ // if (check_privs())
+ // exit(EXIT_FAILURE);

if (verbose)
printf("Max CPUs = %d\n", max_cpus);
22 changes: 22 additions & 0 deletions repo/packages/r/rt-tests/patches/1.0/03_Makefile.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/Makefile b/Makefile
index 569adc1..3fae87e 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,7 @@ $(OBJDIR):
mkdir $(OBJDIR)

# Include dependency files, automatically generate them if needed.
--include $(addprefix $(OBJDIR)/,$(sources:.c=.d))
+# -include $(addprefix $(OBJDIR)/,$(sources:.c=.d))

cyclictest: $(OBJDIR)/cyclictest.o $(OBJDIR)/librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(RTTESTLIB) $(NUMA_LIBS)
@@ -162,7 +162,7 @@ rebuild:
$(MAKE) all

.PHONY: install
-install: all install_hwlatdetect
+install: install_hwlatdetect
mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(mandir)/man4"
mkdir -p "$(DESTDIR)$(srcdir)" "$(DESTDIR)$(mandir)/man8"
cp $(TARGETS) "$(DESTDIR)$(bindir)"
Loading

0 comments on commit 7902de9

Please sign in to comment.