Skip to content

Commit 973db7e

Browse files
authored
Merge pull request #28 from foss-for-synopsys-dwc-arc-processors/luis_qemu_testsuite_wip
Integrated the QEMU testsuite port for DejaGNU. Signed-off-by: Luis Silva [email protected]
2 parents 4c27b4c + 2b405ab commit 973db7e

File tree

249 files changed

+14992
-1382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+14992
-1382
lines changed

Makefile.in

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,38 @@ else
100100
endif
101101
endif
102102

103+
ifeq (@default_target@,linux)
104+
TARGET_ALIAS = $(call make_tuple,linux-gnu)
105+
TARGET_TRIPLET = $(call make_tupple,unknown-linux-gnu)
106+
else
107+
ifeq (@target_alias@,arc)
108+
TARGET_ALIAS = $(call make_tuple,elf32)
109+
TARGET_TRIPLET = $(call make_tuple,unknown-elf32)
110+
else
111+
TARGET_ALIAS = $(call make_tuple,elf)
112+
TARGET_TRIPLET = $(call make_tuple,unknown-elf)
113+
endif
114+
endif
115+
103116
ifeq ($(SIM),qemu)
104117
# Using qemu simulator.
105118
SIM_STAMP:= stamps/build-qemu
119+
SIM_PATH:=$(srcdir)/scripts/wrapper/$(SIM)
120+
SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" ARC_SYSROOT="$(SYSROOT)" DEJAGNU="$(srcdir)/dejagnu/site.exp" DEJAGNU_SIM_OPTIONS="-Wq,-semihosting" QEMU_CPU="$(QEMU_CPU)"
106121
else
107122
ifeq ($(SIM),nsim)
108123
# Using nsim simulator.
109124
ifeq (@default_target@, linux)
110125
$(error nSIM not supported)
111126
endif
112127
SIM_STAMP:= nsim-validation
128+
SIM_PATH:=$(srcdir)/scripts/wrapper/$(SIM)
129+
SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" ARC_SYSROOT="$(SYSROOT)" DEJAGNU="$(srcdir)/dejagnu/site.exp" QEMU_CPU="$(QEMU_CPU)"
113130
else
114131
$(error Only support SIM=nsim, or SIM=qemu (default))
115132
endif
116133
endif
117134

118-
SIM_PATH:=$(srcdir)/scripts/wrapper/$(SIM)
119-
SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" ARC_SYSROOT="$(SYSROOT)" DEJAGNU="$(srcdir)/dejagnu/site.exp" QEMU_CPU="$(QEMU_CPU)"
120-
121-
122135
all: @default_target@ @qemu_build@
123136
echo "$(INSTALL_DIR)" > stamps/install_dir
124137
baremetal: stamps/build-gcc-newlib-stage2
@@ -147,6 +160,9 @@ check-binutils: check-binutils-@default_target@
147160
check-binutils-linux: stamps/check-binutils-linux
148161
check-binutils-baremetal: stamps/check-binutils-baremetal
149162

163+
check-qemu: check-qemu-@default_target@
164+
check-qemu-baremetal: stamps/check-qemu-baremetal
165+
150166
check-newlib-baremetal:stamps/check-newlib-baremetal
151167

152168
.PHONY: report
@@ -156,6 +172,7 @@ report-linux: $(patsubst %,report-%-linux,$(REGRESSION_TEST_LIST))
156172
report-baremetal: $(patsubst %,report-%-baremetal,$(REGRESSION_TEST_LIST))
157173

158174
.PHONY: report-newlib-@default_target@ report-binutils-@default_target@
175+
report-qemu: report-qemu-@default_target@
159176
report-gcc: report-gcc-@default_target@
160177
report-binutils: report-binutils-@default_target@
161178
report-newlib: report-newlib-@default_target@
@@ -527,6 +544,22 @@ stamps/build-qemu: $(QEMU_SRCDIR)
527544
$(MAKE) -C $(notdir $@) install
528545
mkdir -p $(dir $@) && touch $@
529546

547+
stamps/build-test-qemu: $(srcdir)/test-qemu
548+
rm -rf $@ $(notdir $@)
549+
mkdir $(notdir $@)
550+
cd $(notdir $@) && $</configure \
551+
--with-alias=$(TARGET_ALIAS) \
552+
--with-triplet=$(TARGET_TRIPLET)
553+
mkdir -p $(dir $@) && touch $@
554+
555+
stamps/check-qemu-baremetal: stamps/build-gcc-newlib-stage2 $(SIM_STAMP) stamps/build-test-qemu
556+
ifneq ($(SIM),qemu)
557+
$(error QEMU simulator must be used)
558+
endif
559+
$(SIM_PREPARE) DEJAGNU_SIM_OPTIONS="-Wq,-serial -Wq,stdio" $(MAKE) -C build-test-qemu check "RUNTESTFLAGS=$(RUNTESTFLAGS) --target_board='$(NEWLIB_TARGET_BOARDS)'" || true
560+
mkdir -p $(dir $@)
561+
date > $@
562+
530563
stamps/check-gcc-linux: stamps/build-gcc-linux-stage2 $(SIM_STAMP)
531564
$(SIM_PREPARE) $(MAKE) -C build-gcc-linux-stage2 check-gcc "RUNTESTFLAGS=$(RUNTESTFLAGS) --target_board='$(GLIBC_TARGET_BOARDS)'"
532565
mkdir -p $(dir $@)
@@ -554,6 +587,11 @@ ifeq ($(shell command -v nsimdrv),)
554587
$(error nsimdrv not detected)
555588
endif
556589

590+
report-qemu-baremetal: stamps/check-qemu-baremetal
591+
$(srcdir)/scripts/testsuite-filter newlib \
592+
$(srcdir)/test/allowlist/qemu/$(QEMU_CPU)/qemu.json \
593+
`find build-test-qemu -name *.sum |paste -sd "," -`
594+
557595
report-gcc-baremetal: stamps/check-gcc-baremetal
558596
$(srcdir)/scripts/testsuite-filter newlib \
559597
$(srcdir)/test/allowlist/gcc/$(QEMU_CPU)/gcc.json \

dejagnu/baseboards/arc-sim.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ set_board_info noargs 1
5656
set_board_info gdb,nosignals 1
5757
set_board_info sim_time_limit 300
5858

59+
# Provides options to the simulator's execution call.
60+
if {[info exists ::env(DEJAGNU_SIM_OPTIONS)]} {
61+
set_board_info sim,options "$env(DEJAGNU_SIM_OPTIONS)"
62+
}
63+
5964
# skip gdb.reverse
6065
set_board_info gdb,can_reverse 0
6166
set_board_info gdb,use_precord 0

scripts/wrapper/qemu/arc64-elf-run

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ qemu_args=()
44
while [[ "$1" != "" ]]
55
do
66
case "$1" in
7-
-Wq,*) qemu_args+=("$echo "$1" | cut -d, -f2-)");;
7+
-Wq,*) qemu_args+=("$(echo "$1" | cut -d, -f2-)");;
88
*) break;;
99
esac
1010
shift
@@ -13,9 +13,11 @@ done
1313
xlen="$(readelf -h $1 | grep 'Class' | cut -d: -f 2 | xargs echo | sed 's/^ELF//')"
1414

1515
case "$xlen" in
16-
64) qemu="64";;
17-
*) qemu="";;
16+
64) qemu="64"
17+
mem="3G";;
18+
*) qemu=""
19+
mem="2G";;
1820
esac
1921

20-
qemu-system-arc$qemu -semihosting -cpu ${QEMU_CPU} -M arc-sim -m 2G -nographic \
22+
qemu-system-arc$qemu -cpu ${QEMU_CPU} -M arc-sim -m $mem "${qemu_args[@]}" -nographic \
2123
-no-reboot -monitor none -kernel "$@"

test-qemu/Makefile.in

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
srcdir = @srcdir@
2+
target_alias = @target_alias@
3+
target_triplet = @target_triplet@
4+
5+
site.exp:
6+
@echo "Making a new config file..."
7+
@test ! -f site.bak || rm -f site.bak
8+
@echo "## these variables are automatically generated by make ##" > $@-t
9+
@echo "# Do not edit here. If you wish to override these values" >> $@-t
10+
@echo "# add them to the last section" >> $@-t
11+
@echo "set srcdir $(srcdir)/qemu/testsuite" >> $@-t
12+
@echo "set objdir ./" >> $@-t
13+
@echo "set tmpdir ./tmp" >> $@-t
14+
@echo "set target_alias $(target_alias)" >> $@-t
15+
@echo "set target_triplet $(target_triplet)" >> $@-t
16+
@test ! -f site.exp || sed '1./^## All variables above are.*##/ d' site.exp >> $@-t
17+
@test ! -f site.exp || mv site.exp site.bak
18+
@mv $@-t site.exp
19+
20+
check: site.exp
21+
@if [ -d tmp ] ; then \
22+
true ; \
23+
else \
24+
mkdir tmp ; \
25+
fi
26+
runtest --tool qemu $(RUNTESTFLAGS) || true

0 commit comments

Comments
 (0)