ソースを参照

fix: testcases and build system
- Add default ARM toolchain fallback in Makefile
- Unify embedded test execution with './test' script
- Fix documentation commands
Signed-off-by: Jiajie Zhou 2293611667@qq.com

Chris 5 ヶ月 前
コミット
97a550a240
3 ファイル変更22 行追加8 行削除
  1. 5 0
      Makefile
  2. 16 7
      testcases/Makefile
  3. 1 1
      testcases/README.md

+ 5 - 0
Makefile

@@ -4,6 +4,11 @@ endif
 
 PROJECT_PATH := .
 
+# Set default toolchain if MLIBC_TOOLCHAIN is not set
+ifeq ($(MLIBC_TOOLCHAIN),)
+    MLIBC_TOOLCHAIN := $(PROJECT_PATH)/toolchain/arm-linux-eabi_for_x86_64-pc-linux-gnu/bin/arm-linux-eabi-
+endif
+
 CC := $(MLIBC_TOOLCHAIN)gcc
 AR := $(MLIBC_TOOLCHAIN)ar
 

+ 16 - 7
testcases/Makefile

@@ -99,7 +99,7 @@ embedded-build: check-mlibc
 .PHONY: embedded-test
 embedded-test: embedded-build
 	@echo "$(BLUE)Running embedded tests...$(NC)"
-	@./run_all_embedded_tests.sh
+	@./test
 
 .PHONY: embedded-clean
 embedded-clean:
@@ -143,8 +143,8 @@ pc-test-$(1):
 .PHONY: embedded-test-$(1)
 embedded-test-$(1): check-mlibc
 	@echo "$(BLUE)Testing $(1) (embedded)...$(NC)"
-	@if [ -f $(1)/run_embedded_test.sh ]; then \
-		cd $(1) && ./run_embedded_test.sh; \
+	@if [ -f $(1)/test ]; then \
+		cd $(1) && ./test; \
 	else \
 		echo "$(RED)No embedded tests for $(1)$(NC)"; \
 	fi
@@ -155,11 +155,20 @@ $(foreach dir,$(TEST_DIRS),$(eval $(call INDIVIDUAL_TEST_RULES,$(dir))))
 # Check if mlibc is built
 .PHONY: check-mlibc
 check-mlibc:
-	@if [ ! -f ../build/riscv32/libmlibc.a ]; then \
-		echo "$(YELLOW)Building mlibc for RISC-V 32-bit...$(NC)"; \
-		$(MAKE) -C .. ARCH=riscv32 || { \
+	@ARCH=$${EMBEDDED_ARCH:-riscv32}; \
+	if [ ! -f ../build/$$ARCH/libmlibc.a ]; then \
+		if [ "$$ARCH" = "arm" ]; then \
+			echo "$(YELLOW)Building mlibc for ARM...$(NC)"; \
+		elif [ "$$ARCH" = "aarch64" ]; then \
+			echo "$(YELLOW)Building mlibc for AArch64...$(NC)"; \
+		elif [ "$$ARCH" = "riscv64" ]; then \
+			echo "$(YELLOW)Building mlibc for RISC-V 64-bit...$(NC)"; \
+		else \
+			echo "$(YELLOW)Building mlibc for RISC-V 32-bit...$(NC)"; \
+		fi; \
+		$(MAKE) -C .. ARCH=$$ARCH || { \
 			echo "$(RED)Failed to build mlibc!$(NC)"; \
-			echo "Please ensure you have the RISC-V toolchain installed."; \
+			echo "Please ensure you have the $$ARCH toolchain installed."; \
 			echo "Set MLIBC_TOOLCHAIN environment variable if needed."; \
 			exit 1; \
 		}; \

+ 1 - 1
testcases/README.md

@@ -77,7 +77,7 @@ EMBEDDED_ARCH=arm make embedded
 EMBEDDED_ARCH=aarch64 make embedded
 
 # 运行嵌入式测试
-EMBEDDED_ARCH=arm make run
+EMBEDDED_ARCH=arm make test
 ```
 
 ### 文件组织特点