Skip to content

Commit a526a4a

Browse files
xianglycxiaoxiang781216
authored andcommitted
app/testing:Add x86_64 abi test cases
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com> app/testing:Add x86_64 abi test download path Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
1 parent e260522 commit a526a4a

File tree

4 files changed

+308
-0
lines changed

4 files changed

+308
-0
lines changed
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
From e04cc6b038201e4751ba8e582d81089c291684c4 Mon Sep 17 00:00:00 2001
2+
From: liwenxiang1 <liwenxiang1@xiaomi.com>
3+
Date: Tue, 30 Jul 2024 17:53:49 +0800
4+
Subject: [PATCH] app/testing:Resolve the issue of compilation failure for
5+
x86_64 abi test cases
6+
7+
VELAPLATFO-37440
8+
9+
The source code is compiled and run separately for each case, so compiling all cases together may result in duplicate variable definitions. We put the variables in header files and declare them as static
10+
11+
Change-Id: Iddfb1caf5fc21dec1682b34b2e940df0c62f6499
12+
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
13+
---
14+
abitest/args.h | 10 +++++-----
15+
abitest/defines.h | 1 -
16+
abitest/make_passing_tests.c | 4 ----
17+
abitest/test_complex_returning.c | 5 -----
18+
abitest/test_m64m128_returning.c | 4 ----
19+
abitest/test_passing_m64m128.c | 4 ----
20+
abitest/test_passing_structs.c | 4 ----
21+
abitest/test_passing_structs_and_unions.c | 4 ----
22+
abitest/test_passing_unions.c | 4 ----
23+
abitest/test_struct_returning.c | 4 ----
24+
10 files changed, 5 insertions(+), 39 deletions(-)
25+
26+
diff --git a/abitest/args.h b/abitest/args.h
27+
index 586271e..a91bea2 100644
28+
--- a/abitest/args.h
29+
+++ b/abitest/args.h
30+
@@ -39,8 +39,8 @@ typedef union {
31+
} X87_T;
32+
extern void (*callthis)(void);
33+
extern unsigned long rax,rbx,rcx,rdx,rsi,rdi,rsp,rbp,r8,r9,r10,r11,r12,r13,r14,r15;
34+
-XMM_T xmm_regs[16];
35+
-X87_T x87_regs[8];
36+
+static XMM_T xmm_regs[16];
37+
+static X87_T x87_regs[8];
38+
extern volatile unsigned long volatile_var;
39+
extern void snapshot (void);
40+
extern void snapshot_ret (void);
41+
@@ -83,9 +83,9 @@ struct FloatRegisters
42+
};
43+
44+
/* Implemented in scalarargs.c */
45+
-extern struct IntegerRegisters iregs;
46+
-extern struct FloatRegisters fregs;
47+
-extern unsigned int num_iregs, num_fregs;
48+
+static struct IntegerRegisters iregs;
49+
+static struct FloatRegisters fregs;
50+
+static unsigned int num_iregs, num_fregs;
51+
52+
#define check_int_arguments do { \
53+
assert (num_iregs <= 0 || iregs.I0 == I0); \
54+
diff --git a/abitest/defines.h b/abitest/defines.h
55+
index 42b1426..185d78b 100644
56+
--- a/abitest/defines.h
57+
+++ b/abitest/defines.h
58+
@@ -3,7 +3,6 @@
59+
60+
typedef unsigned long ulong;
61+
typedef long double ldouble;
62+
-typedef __int128_t __int128;
63+
typedef __uint128_t __uint128;
64+
65+
/* These defines determines what part of the test should be run. When
66+
diff --git a/abitest/make_passing_tests.c b/abitest/make_passing_tests.c
67+
index 9569147..e9e1eda 100644
68+
--- a/abitest/make_passing_tests.c
69+
+++ b/abitest/make_passing_tests.c
70+
@@ -62,10 +62,6 @@ open_file (char *filename, int use_ints, int use_floats)
71+
fprintf (file, "#include \"macros.h\"\n");
72+
fprintf (file, "#include \"args.h\"\n\n");
73+
74+
- fprintf (file, "struct IntegerRegisters iregs;\n");
75+
- fprintf (file, "struct FloatRegisters fregs;\n");
76+
- fprintf (file, "unsigned int num_iregs, num_fregs;\n\n");
77+
-
78+
/* Make the struct for checking the parameter values. */
79+
fprintf (file, "/* This struct holds values for argument checking. */\n");
80+
if (use_ints)
81+
diff --git a/abitest/test_complex_returning.c b/abitest/test_complex_returning.c
82+
index fa2bb70..af5e278 100644
83+
--- a/abitest/test_complex_returning.c
84+
+++ b/abitest/test_complex_returning.c
85+
@@ -4,11 +4,6 @@
86+
#include "defines.h"
87+
#include "args.h"
88+
89+
-
90+
-struct IntegerRegisters iregs;
91+
-struct FloatRegisters fregs;
92+
-unsigned int num_iregs, num_fregs;
93+
-
94+
#define BUILD_F_COMPLEX(real, imag) \
95+
({ __complex__ float __retval = 0; \
96+
__real__ __retval = (real); \
97+
diff --git a/abitest/test_m64m128_returning.c b/abitest/test_m64m128_returning.c
98+
index cde0346..631bc0c 100644
99+
--- a/abitest/test_m64m128_returning.c
100+
+++ b/abitest/test_m64m128_returning.c
101+
@@ -3,10 +3,6 @@
102+
#include "macros.h"
103+
#include "args.h"
104+
105+
-struct IntegerRegisters iregs;
106+
-struct FloatRegisters fregs;
107+
-unsigned int num_iregs, num_fregs;
108+
-
109+
__m64
110+
fun_test_returning___m64 (void)
111+
{
112+
diff --git a/abitest/test_passing_m64m128.c b/abitest/test_passing_m64m128.c
113+
index 2a2f98f..83a419a 100644
114+
--- a/abitest/test_passing_m64m128.c
115+
+++ b/abitest/test_passing_m64m128.c
116+
@@ -3,10 +3,6 @@
117+
#include "macros.h"
118+
#include "args.h"
119+
120+
-struct IntegerRegisters iregs;
121+
-struct FloatRegisters fregs;
122+
-unsigned int num_iregs, num_fregs;
123+
-
124+
/* This struct holds values for argument checking. */
125+
struct
126+
{
127+
diff --git a/abitest/test_passing_structs.c b/abitest/test_passing_structs.c
128+
index 211c700..0cbbbf0 100644
129+
--- a/abitest/test_passing_structs.c
130+
+++ b/abitest/test_passing_structs.c
131+
@@ -3,10 +3,6 @@
132+
#include "defines.h"
133+
#include "args.h"
134+
135+
-struct IntegerRegisters iregs;
136+
-struct FloatRegisters fregs;
137+
-unsigned int num_iregs, num_fregs;
138+
-
139+
struct int_struct
140+
{
141+
int i;
142+
diff --git a/abitest/test_passing_structs_and_unions.c b/abitest/test_passing_structs_and_unions.c
143+
index 5b40196..593d9b7 100644
144+
--- a/abitest/test_passing_structs_and_unions.c
145+
+++ b/abitest/test_passing_structs_and_unions.c
146+
@@ -3,10 +3,6 @@
147+
#include "defines.h"
148+
#include "args.h"
149+
150+
-struct IntegerRegisters iregs;
151+
-struct FloatRegisters fregs;
152+
-unsigned int num_iregs, num_fregs;
153+
-
154+
struct int_struct
155+
{
156+
int i;
157+
diff --git a/abitest/test_passing_unions.c b/abitest/test_passing_unions.c
158+
index 0b60704..4d71333 100644
159+
--- a/abitest/test_passing_unions.c
160+
+++ b/abitest/test_passing_unions.c
161+
@@ -3,10 +3,6 @@
162+
#include "defines.h"
163+
#include "args.h"
164+
165+
-struct IntegerRegisters iregs;
166+
-struct FloatRegisters fregs;
167+
-unsigned int num_iregs, num_fregs;
168+
-
169+
struct int_struct
170+
{
171+
int i;
172+
diff --git a/abitest/test_struct_returning.c b/abitest/test_struct_returning.c
173+
index ef8d329..f517bd5 100644
174+
--- a/abitest/test_struct_returning.c
175+
+++ b/abitest/test_struct_returning.c
176+
@@ -5,10 +5,6 @@
177+
#include "macros.h"
178+
#include "args.h"
179+
180+
-struct IntegerRegisters iregs;
181+
-struct FloatRegisters fregs;
182+
-unsigned int num_iregs, num_fregs;
183+
-
184+
int current_test;
185+
int num_failed = 0;
186+
187+
--
188+
2.34.1
189+

testing/x86-64-ABI/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config TESTING_X86_64_ABI
7+
bool "X86_64_ABI testing support"
8+
default n
9+
depends on ALLOW_GPL_COMPONENTS
10+
---help---
11+
Enable support for the X86_64_ABI testing framework

testing/x86-64-ABI/Make.defs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
############################################################################
2+
# apps/system/uorb/Make.defs
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
ifneq ($(CONFIG_TESTING_X86_64_ABI),)
22+
CONFIGURED_APPS += $(APPDIR)/testing/x86-64-ABI
23+
endif

testing/x86-64-ABI/Makefile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
############################################################################
2+
# apps/testing/x86-64-ABI/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
include $(APPDIR)/Make.defs
22+
23+
X86_64_ABI_COMMIT ?= ab2062ad5653913c39124548943b1177330e34c8
24+
25+
# Download and unpack tarball if no git repo found
26+
27+
ifeq ($(wildcard x86-64-ABI/.git),)
28+
x86-64-ABI.zip:
29+
$(call DOWNLOAD,https://gitlab.com/x86-psABIs/x86-64-ABI/-/archive/$(X86_64_ABI_COMMIT),x86-64-ABI-$(X86_64_ABI_COMMIT).zip,x86-64-ABI.zip)
30+
$(Q) unzip -o x86-64-ABI.zip
31+
mv x86-64-ABI-$(X86_64_ABI_COMMIT) x86-64-ABI
32+
$(Q) patch -p1 -d x86-64-ABI < 0001-app-testing-Resolve-the-issue-of-compilation-failure.patch
33+
34+
context:: x86-64-ABI.zip
35+
endif
36+
37+
distclean::
38+
ifeq ($(wildcard x86-64-ABI/.git),)
39+
$(call DELDIR, x86-64-ABI)
40+
$(call DELFILE, x86-64-ABI.zip)
41+
endif
42+
43+
SUBDIR = x86-64-ABI/abitest
44+
45+
$(SUBDIR)/test_3_element_struct_and_unions.c: $(SUBDIR)/make_3esau.c $(SUBDIR)/typelist.h \
46+
$(SUBDIR)/typelist.c $(SUBDIR)/defines.h $(SUBDIR)/args.h
47+
cd $(SUBDIR) && \
48+
gcc -o make_3esau make_3esau.c typelist.c && \
49+
./make_3esau > test_3_element_struct_and_unions.c
50+
51+
$(SUBDIR)/test_passing_integers.c $(SUBDIR)/test_passing_floats.c: $(SUBDIR)/make_passing_tests.c \
52+
$(SUBDIR)/typelist.h $(SUBDIR)/typelist.c $(SUBDIR)/defines.h $(SUBDIR)/args.h
53+
cd $(SUBDIR) && \
54+
gcc -o make_passing_tests make_passing_tests.c typelist.c && \
55+
./make_passing_tests
56+
57+
$(SUBDIR)/test_basic_returning.c: $(SUBDIR)/make_returning.c $(SUBDIR)/typelist.h $(SUBDIR)/typelist.c \
58+
$(SUBDIR)/defines.h $(SUBDIR)/args.h
59+
cd $(SUBDIR) && \
60+
gcc -o make_returning make_returning.c typelist.c && \
61+
./make_returning > test_basic_returning.c
62+
63+
CSRCS += $(SUBDIR)/test_basic_returning.c $(SUBDIR)/test_passing_integers.c $(SUBDIR)/test_passing_floats.c \
64+
$(SUBDIR)/test_3_element_struct_and_unions.c
65+
66+
ASRCS = $(SUBDIR)/asm-support.S
67+
68+
define add_benchmark
69+
PROGNAME += $1
70+
MAINSRC += $(SUBDIR)/$1.c
71+
PRIORITY += 100
72+
STACKSIZE += $(CONFIG_DEFAULT_TASK_STACKSIZE)
73+
endef
74+
75+
# Add test cases with compilation errors
76+
EXCLUDE = make_3esau make_passing_tests make_returning medium-test typelist
77+
ALL_CASES := $(wildcard x86-64-ABI/abitest/*.c)
78+
79+
# Filter unnecessary files
80+
BENCHMARKS := $(filter-out $(EXCLUDE), $(patsubst %.c,%,$(notdir $(ALL_CASES))))
81+
82+
$(foreach benchmark,$(BENCHMARKS),$(eval $(call add_benchmark,$(benchmark))))
83+
84+
include $(APPDIR)/Application.mk
85+

0 commit comments

Comments
 (0)