Skip to content

Commit 3affe0b

Browse files
authored
Merge pull request #72 from Chris-godz/testcases
fix: testcases and build system
2 parents 1be03a4 + 97a550a commit 3affe0b

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ endif
44

55
PROJECT_PATH := .
66

7+
# Set default toolchain if MLIBC_TOOLCHAIN is not set
8+
ifeq ($(MLIBC_TOOLCHAIN),)
9+
MLIBC_TOOLCHAIN := $(PROJECT_PATH)/toolchain/arm-linux-eabi_for_x86_64-pc-linux-gnu/bin/arm-linux-eabi-
10+
endif
11+
712
CC := $(MLIBC_TOOLCHAIN)gcc
813
AR := $(MLIBC_TOOLCHAIN)ar
914

testcases/Makefile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ embedded-build: check-mlibc
9999
.PHONY: embedded-test
100100
embedded-test: embedded-build
101101
@echo "$(BLUE)Running embedded tests...$(NC)"
102-
@./run_all_embedded_tests.sh
102+
@./test
103103

104104
.PHONY: embedded-clean
105105
embedded-clean:
@@ -143,8 +143,8 @@ pc-test-$(1):
143143
.PHONY: embedded-test-$(1)
144144
embedded-test-$(1): check-mlibc
145145
@echo "$(BLUE)Testing $(1) (embedded)...$(NC)"
146-
@if [ -f $(1)/run_embedded_test.sh ]; then \
147-
cd $(1) && ./run_embedded_test.sh; \
146+
@if [ -f $(1)/test ]; then \
147+
cd $(1) && ./test; \
148148
else \
149149
echo "$(RED)No embedded tests for $(1)$(NC)"; \
150150
fi
@@ -155,11 +155,20 @@ $(foreach dir,$(TEST_DIRS),$(eval $(call INDIVIDUAL_TEST_RULES,$(dir))))
155155
# Check if mlibc is built
156156
.PHONY: check-mlibc
157157
check-mlibc:
158-
@if [ ! -f ../build/riscv32/libmlibc.a ]; then \
159-
echo "$(YELLOW)Building mlibc for RISC-V 32-bit...$(NC)"; \
160-
$(MAKE) -C .. ARCH=riscv32 || { \
158+
@ARCH=$${EMBEDDED_ARCH:-riscv32}; \
159+
if [ ! -f ../build/$$ARCH/libmlibc.a ]; then \
160+
if [ "$$ARCH" = "arm" ]; then \
161+
echo "$(YELLOW)Building mlibc for ARM...$(NC)"; \
162+
elif [ "$$ARCH" = "aarch64" ]; then \
163+
echo "$(YELLOW)Building mlibc for AArch64...$(NC)"; \
164+
elif [ "$$ARCH" = "riscv64" ]; then \
165+
echo "$(YELLOW)Building mlibc for RISC-V 64-bit...$(NC)"; \
166+
else \
167+
echo "$(YELLOW)Building mlibc for RISC-V 32-bit...$(NC)"; \
168+
fi; \
169+
$(MAKE) -C .. ARCH=$$ARCH || { \
161170
echo "$(RED)Failed to build mlibc!$(NC)"; \
162-
echo "Please ensure you have the RISC-V toolchain installed."; \
171+
echo "Please ensure you have the $$ARCH toolchain installed."; \
163172
echo "Set MLIBC_TOOLCHAIN environment variable if needed."; \
164173
exit 1; \
165174
}; \

testcases/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ EMBEDDED_ARCH=arm make embedded
7777
EMBEDDED_ARCH=aarch64 make embedded
7878

7979
# 运行嵌入式测试
80-
EMBEDDED_ARCH=arm make run
80+
EMBEDDED_ARCH=arm make test
8181
```
8282

8383
### 文件组织特点

0 commit comments

Comments
 (0)