application exit error handing
This commit is contained in:
39
tests/runtime/fibonacci/Makefile
Normal file
39
tests/runtime/fibonacci/Makefile
Normal file
@@ -0,0 +1,39 @@
|
||||
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
|
||||
VORTEX_RT_PATH ?= $(realpath ../../../runtime)
|
||||
|
||||
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
|
||||
AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
|
||||
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
|
||||
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
|
||||
|
||||
CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wstack-usage=1024 -ffreestanding -nostartfiles -fdata-sections -ffunction-sections
|
||||
CFLAGS += -I$(VORTEX_RT_PATH)/include -I$(VORTEX_RT_PATH)/../hw
|
||||
|
||||
LDFLAGS += -lm -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a
|
||||
|
||||
PROJECT = fibonacci
|
||||
|
||||
SRCS = main.cpp
|
||||
|
||||
all: $(PROJECT).elf $(PROJECT).hex $(PROJECT).dump
|
||||
|
||||
$(PROJECT).dump: $(PROJECT).elf
|
||||
$(DP) -D $(PROJECT).elf > $(PROJECT).dump
|
||||
|
||||
$(PROJECT).hex: $(PROJECT).elf
|
||||
$(CP) -O ihex $(PROJECT).elf $(PROJECT).hex
|
||||
|
||||
$(PROJECT).elf: $(SRCS)
|
||||
$(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT).elf
|
||||
|
||||
run: $(PROJECT).hex
|
||||
../../../hw/simulate/obj_dir/VVortex $(PROJECT).hex
|
||||
|
||||
run-simx: $(PROJECT).hex
|
||||
../../../simX/simX -a rv32i -i $(PROJECT).hex
|
||||
|
||||
.depend: $(SRCS)
|
||||
$(CC) $(CFLAGS) -MM $^ > .depend;
|
||||
|
||||
clean:
|
||||
rm -rf *.elf *.hex *.dump .depend
|
||||
96973
tests/runtime/fibonacci/fibonacci.dump
Normal file
96973
tests/runtime/fibonacci/fibonacci.dump
Normal file
File diff suppressed because it is too large
Load Diff
BIN
tests/runtime/fibonacci/fibonacci.elf
Executable file
BIN
tests/runtime/fibonacci/fibonacci.elf
Executable file
Binary file not shown.
5774
tests/runtime/fibonacci/fibonacci.hex
Normal file
5774
tests/runtime/fibonacci/fibonacci.hex
Normal file
File diff suppressed because it is too large
Load Diff
32
tests/runtime/fibonacci/main.cpp
Normal file
32
tests/runtime/fibonacci/main.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
|
||||
const int Num = 9;
|
||||
const int Ans = 34;
|
||||
|
||||
int fibonacci(int n) {
|
||||
if (n <= 1)
|
||||
return n;
|
||||
return fibonacci(n-1) + fibonacci(n-2);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int errors = 0;
|
||||
|
||||
int fib = fibonacci(Num);
|
||||
|
||||
printf("fibonacci(%d) = %d\n", Num, fib);
|
||||
|
||||
if (fib == Ans) {
|
||||
printf("Passed!\n");
|
||||
} else {
|
||||
printf("Failed! value=%d, expected=%d\n", fib, Ans);
|
||||
errors = 1;
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user