Skip to content

Commit

Permalink
[libc++] Run picolibc tests with qemu
Browse files Browse the repository at this point in the history
This patch actually runs the tests for picolibc behind an emulator,
removing a few workarounds and increasing coverage.

Differential Revision: https://reviews.llvm.org/D155521
  • Loading branch information
mplatings authored and ldionne committed Nov 29, 2023
1 parent b92bf0d commit be811d1
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 16 deletions.
3 changes: 3 additions & 0 deletions libcxx/cmake/caches/Armv7M-picolibc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")
set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
# Long tests are prohibitively slow when run via emulation.
set(LIBCXX_TEST_PARAMS "long_tests=False" CACHE STRING "")
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
set(LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "")
set(LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "")
set(LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "")
set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
find_program(QEMU_SYSTEM_ARM qemu-system-arm)
2 changes: 1 addition & 1 deletion libcxx/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Linux i386, x86_64, arm, arm64 Only glibc-2.24 and later and no
Android 5.0+ i386, x86_64, arm, arm64
Windows i386, x86_64 Both MSVC and MinGW style environments, ABI in MSVC environments is :doc:`unstable <DesignDocs/ABIVersioning>`
AIX 7.2TL5+ powerpc, powerpc64
Embedded (picolibc) arm Support for building with picolibc is currently work-in-progress
Embedded (picolibc) arm
===================== ========================= ============================

Generally speaking, libc++ should work on any platform that provides a fairly complete
Expand Down
10 changes: 8 additions & 2 deletions libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ config.substitutions.append(('%{link_flags}',
' -Wl,--defsym=__ram_size=0x1000000'
' -Wl,--defsym=__stack_size=0x1000'
))

config.executor = (
'@LIBCXX_SOURCE_DIR@/utils/qemu_baremetal.py'
' --qemu @QEMU_SYSTEM_ARM@'
' --machine mps2-an385'
' --cpu cortex-m3')
config.substitutions.append(('%{exec}',
'true' # TODO use qemu-system-arm
'%{executor}'
' --execdir %T'
))
config.available_features.add('libcxx-fake-executor')

import os, site
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
Expand Down
4 changes: 3 additions & 1 deletion libcxx/test/libcxx/selftest/dsl/dsl.sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#
# ===----------------------------------------------------------------------===##

# XFAIL: libcxx-fake-executor
# With picolibc, test_program_stderr_is_not_conflated_with_stdout fails
# because stdout & stderr are treated as the same.
# XFAIL: LIBCXX-PICOLIBC-FIXME

# Note: We prepend arguments with 'x' to avoid thinking there are too few
# arguments in case an argument is an empty string.
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/selftest/pass.cpp/run-error.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: libcxx-fake-executor
// XFAIL: *

// Make sure the test DOES NOT pass if it fails at runtime.
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/selftest/pass.mm/run-error.pass.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

// REQUIRES: objective-c++
// UNSUPPORTED: libcxx-fake-executor

// XFAIL: *

Expand Down
2 changes: 2 additions & 0 deletions libcxx/test/libcxx/selftest/stdin-is-piped.sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

// Make sure that the executor pipes standard input to the test-executable being run.

// XFAIL: LIBCXX-PICOLIBC-FIXME

// RUN: %{build}
// RUN: echo "abc" | %{exec} %t.exe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//

// This test appears to hang with picolibc & qemu.
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

// <algorithm>

// template<RandomAccessIterator Iter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

// XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12}}
// XFAIL: LIBCXX-PICOLIBC-FIXME

// <system_error>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// const error_category& system_category();

// XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12}}
// XFAIL: LIBCXX-PICOLIBC-FIXME

#include <system_error>
#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
// XFAIL: LIBCXX-PICOLIBC-FIXME

// <iostream>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

// TODO: Investigate
// UNSUPPORTED: LIBCXX-AIX-FIXME
// XFAIL: LIBCXX-PICOLIBC-FIXME

// This test hangs on Android devices that lack shell_v2, which was added in
// Android N (API 24).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
// XFAIL: LIBCXX-PICOLIBC-FIXME

// <iostream>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

// <iostream>

// ostream cout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// test sized operator delete[] replacement.

// UNSUPPORTED: sanitizer-new-delete, c++03, c++11
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
// default. It is only enabled when -fsized-deallocation is given.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// test sized operator delete replacement.

// UNSUPPORTED: sanitizer-new-delete, c++03, c++11
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
// default. It is only enabled when -fsized-deallocation is given.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-PICOLIBC-FIXME

// <locale>

// template <> class ctype<char>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) const;

// XFAIL: win32-broken-printf-g-precision
// XFAIL: LIBCXX-PICOLIBC-FIXME

// Needs more investigation, but this is probably failing on Android M (API 23)
// and up because the printf formatting of NAN changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// Serializing/deserializing the state of the RNG requires iostreams
// UNSUPPORTED: no-localization

// This test appears to hang with picolibc & qemu.
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

#include <random>
#include <numeric>
#include <vector>
Expand Down
3 changes: 3 additions & 0 deletions libcxx/test/std/time/time.clock/time.clock.file/now.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

// UNSUPPORTED: availability-filesystem-missing

// qemu: Unsupported SemiHosting SWI 0x30
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

// <chrono>

// file_clock
Expand Down
10 changes: 8 additions & 2 deletions libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ config.substitutions.append(('%{link_flags}',
' -Wl,--defsym=__ram_size=0x1000000'
' -Wl,--defsym=__stack_size=0x1000'
))

config.executor = (
'@LIBCXXABI_LIBCXX_PATH@/utils/qemu_baremetal.py'
' --qemu @QEMU_SYSTEM_ARM@'
' --machine mps2-an385'
' --cpu cortex-m3')
config.substitutions.append(('%{exec}',
'true' # TODO use qemu-system-arm
'%{executor}'
' --execdir %T'
))
config.available_features.add('libcxx-fake-executor')

import os, site
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
Expand Down
10 changes: 8 additions & 2 deletions libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ config.substitutions.append(('%{link_flags}',
' -Wl,--defsym=__ram_size=0x1000000'
' -Wl,--defsym=__stack_size=0x1000'
))

config.executor = (
'@LIBUNWIND_LIBCXX_PATH@/utils/qemu_baremetal.py'
' --qemu @QEMU_SYSTEM_ARM@'
' --machine mps2-an385'
' --cpu cortex-m3')
config.substitutions.append(('%{exec}',
'true' # TODO use qemu-system-arm
'%{executor}'
' --execdir %T'
))
config.available_features.add('libcxx-fake-executor')

import os, site
site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
Expand Down
3 changes: 3 additions & 0 deletions libunwind/test/libunwind_02.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

// This test fails on older llvm, when built with picolibc.
// XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME

#undef NDEBUG
#include <assert.h>
#include <stdlib.h>
Expand Down

0 comments on commit be811d1

Please sign in to comment.