1
0
mirror of https://github.com/upx/upx.git synced 2025-08-11 22:52:30 +08:00

CI: disable self-test on macos-13

This commit is contained in:
Markus F.X.J. Oberhumer
2023-06-10 11:02:19 +02:00
parent 75e87a58da
commit c585774162
6 changed files with 40 additions and 6 deletions

View File

@ -183,6 +183,7 @@ jobs:
(cd build/extra/clang/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
(cd build/extra/clang/release && DESTDIR=$PWD/Install-with-make make install)
- name: 'Run basic tests'
if: ${{ !contains(matrix.os, 'macos-13') }} # FIXME: UPX on macos-13 is broken => disable self-test for now
run: |
make -C build/extra/clang/debug test
make -C build/extra/clang/release test

View File

@ -117,6 +117,17 @@ ACC_COMPILE_TIME_ASSERT_HEADER(bswap32(0x04030201) == 0x01020304)
ACC_COMPILE_TIME_ASSERT_HEADER(bswap64(0x0807060504030201ull) == 0x0102030405060708ull)
#endif
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == sizeof(int))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof('a') == sizeof(char))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("") == 1)
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("a") == 2)
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0) == sizeof(int))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0L) == sizeof(long))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0LL) == sizeof(long long))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(nullptr) == sizeof(void *))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(sizeof(0)) == sizeof(size_t))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(usizeof(0)) == sizeof(unsigned))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("") == 0)
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("a") == 1)
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("ab") == 2)
@ -165,6 +176,10 @@ namespace {
template <class T>
struct CheckIntegral {
struct TestT {
T a;
T x[2];
};
template <class U>
struct TestU {
U a = {};
@ -213,6 +228,21 @@ struct CheckIntegral {
COMPILE_TIME_ASSERT(upx_is_integral_v<U>)
}
static void check(void) {
{
TestT t = {};
assert(t.a == 0);
assert(t.x[0] == 0 && t.x[1] == 0);
}
{
const TestT t = {};
assert(t.a == 0);
assert(t.x[0] == 0 && t.x[1] == 0);
}
{
constexpr TestT t = {};
assert(t.a == 0);
assert(t.x[0] == 0 && t.x[1] == 0);
}
checkU<T>();
checkU<typename std::add_const<T>::type>();
}

View File

@ -378,17 +378,18 @@ struct UnsignedSizeOf {
static constexpr unsigned value = unsigned(Size);
};
#define usizeof(expr) (UnsignedSizeOf<sizeof(expr)>::value)
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == sizeof(int))
template <class T>
inline void mem_clear(T *object) noexcept {
static_assert(std::is_class_v<T>);
static_assert(std::is_standard_layout_v<T>);
static_assert(std::is_trivially_copyable_v<T>);
static constexpr size_t size = sizeof(*object);
constexpr size_t size = sizeof(*object);
static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM);
memset((void *) object, 0, size);
}
template <class T>
inline void mem_clear(T (&array)[]) noexcept = delete;
template <class T, size_t N>
inline void mem_clear(T (&array)[N]) noexcept = delete;

View File

@ -252,8 +252,10 @@ void OutputFile::write(SPAN_0(const void) buf, int len) {
return;
mem_size_assert(1, len); // sanity check
errno = 0;
#if WITH_XSPAN >= 2
NO_fprintf(stderr, "write %p %zd (%p) %d\n", buf.raw_ptr(), buf.raw_size_in_bytes(),
buf.raw_base(), len);
#endif
long l = acc_safe_hwrite(_fd, raw_bytes(buf, len), len);
if (l != len)
throwIOException("write error", errno);

View File

@ -674,14 +674,14 @@ bool file_exists(const char *name) {
}
/* return true if we can stat it */
// memset(&st, 0, sizeof(st));
// mem_clear(&st);
r = stat(name, &st);
if (r != -1)
return true;
/* return true if we can lstat it */
#if (HAVE_LSTAT)
// memset(&st, 0, sizeof(st));
// mem_clear(&st);
r = lstat(name, &st);
if (r != -1)
return true;

View File

@ -126,8 +126,8 @@ inline R *xspan_make_helper__(R * /*dummy*/, std::nullptr_t /*first*/) {
return nullptr;
}
template <class R>
inline R *xspan_make_helper__(R * /*dummy*/, MemBuffer &first) {
return (R *) membuffer_get_void_ptr(first);
inline R *xspan_make_helper__(R * /*dummy*/, MemBuffer &mb) {
return (R *) membuffer_get_void_ptr(mb);
}
#define XSPAN_0(type) type *