summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-10-15 04:38:39 -0600
committerTom Rini <trini@ti.com>2014-10-27 11:04:01 -0400
commitb01495e644db8315bd32b9e8d324487ef4f5b4f6 (patch)
treea79534c7a2efb8529e23ac4d07a4f5c2722ac116 /test
parent4fd074de03787ac0f6dfa61da7af230cb76714ff (diff)
downloadblackbird-obmc-uboot-b01495e644db8315bd32b9e8d324487ef4f5b4f6.tar.gz
blackbird-obmc-uboot-b01495e644db8315bd32b9e8d324487ef4f5b4f6.zip
test: Add a simple test to detected warnings with uint64_t, uintptr_t
These types are problematic because they are typically declared in a non-standard way in U-Boot. For example, U-Boot uses 'long long' for int64_t even on a 64-bit machine whereas stdint.h uses 'long'. Similarly, U-Boot always uses 'long' for intptr_t whereas stdint.h mostly uses 'int'. This simple test script runs a few toolchains on a few archs to check for warnings. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/stdint/int-types.c13
-rwxr-xr-xtest/stdint/test-includes.sh58
2 files changed, 71 insertions, 0 deletions
diff --git a/test/stdint/int-types.c b/test/stdint/int-types.c
new file mode 100644
index 0000000000..2660084d94
--- /dev/null
+++ b/test/stdint/int-types.c
@@ -0,0 +1,13 @@
+#include <common.h>
+#include <inttypes.h>
+
+int test_types(void)
+{
+ uintptr_t uintptr = 0;
+ uint64_t uint64 = 0;
+ u64 u64_val = 0;
+
+ printf("uintptr = %" PRIuPTR "\n", uintptr);
+ printf("uint64 = %" PRIu64 "\n", uint64);
+ printf("u64 = %" PRIu64 "\n", u64_val);
+}
diff --git a/test/stdint/test-includes.sh b/test/stdint/test-includes.sh
new file mode 100755
index 0000000000..077bdc73a1
--- /dev/null
+++ b/test/stdint/test-includes.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Test script to check uintptr_t and 64-bit types for warnings
+#
+# It builds a few boards with different toolchains. If there are no warnings
+# then all is well.
+#
+# Usage:
+#
+# Make sure that your toolchains are correct at the bottom of this file
+#
+# Then:
+# ./test/stdint/test-includes.sh
+
+out=/tmp/test-includes.tmp
+
+try_test() {
+ local board=$1
+ local arch=$2
+ local soc=$3
+ local gcc=$4
+ local flags="$5"
+
+ echo $@
+ if ! which ${gcc} >/dev/null 2>&1; then
+ echo "Not found: ${gcc}"
+ return
+ fi
+
+ rm -rf ${out}
+ mkdir -p ${out}
+ touch ${out}/config.h
+ mkdir -p ${out}/generated
+ touch ${out}/generated/generic-asm-offsets.h
+ mkdir -p ${out}/include/asm
+ ln -s $(pwd)/arch/${arch}/include/asm/arch-${soc} \
+ ${out}/include/asm/arch
+
+ cmd="${gcc} -c -D__KERNEL__ ${flags} \
+ -fno-builtin -ffreestanding \
+ -Iarch/${arch}/include \
+ -Iinclude \
+ -I${out} -I${out}/include \
+ -include configs/${board}.h test/stdint/int-types.c \
+ -o /dev/null"
+ $cmd
+}
+
+# Run a test with and without CONFIG_USE_STDINT
+try_both() {
+ try_test $@
+ try_test $@ -DCONFIG_USE_STDINT
+}
+
+# board arch soc path-to-gcc
+try_both sandbox sandbox - gcc
+try_both coreboot x86 - x86_64-linux-gnu-gcc
+try_both seaboard arm tegra20 /opt/linaro/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux/bin/arm-linux-gnueabihf-gcc
OpenPOWER on IntegriCloud