Merge pull request #11031 from poettering/gcc-attr-cleanup
various gcc attribute clean-ups
This commit is contained in:
@@ -177,6 +177,10 @@ tests += [
|
||||
[],
|
||||
[]],
|
||||
|
||||
[['src/test/test-static-destruct.c'],
|
||||
[],
|
||||
[]],
|
||||
|
||||
[['src/test/test-sigbus.c'],
|
||||
[],
|
||||
[]],
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
static uid_t test_uid = -1;
|
||||
static gid_t test_gid = -1;
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
#if HAS_FEATURE_ADDRESS_SANITIZER
|
||||
/* Keep CAP_SYS_PTRACE when running under Address Sanitizer */
|
||||
static const uint64_t test_flags = UINT64_C(1) << CAP_SYS_PTRACE;
|
||||
#else
|
||||
|
||||
@@ -759,7 +759,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
#if HAS_FEATURE_ADDRESS_SANITIZER
|
||||
if (is_run_on_travis_ci()) {
|
||||
log_notice("Running on TravisCI under ASan, skipping, see https://github.com/systemd/systemd/issues/10696");
|
||||
return EXIT_TEST_SKIP;
|
||||
|
||||
@@ -19,7 +19,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
#if HAS_FEATURE_ADDRESS_SANITIZER
|
||||
return log_tests_skipped("address-sanitizer is enabled");
|
||||
#endif
|
||||
#if HAVE_VALGRIND_VALGRIND_H
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "static-destruct.h"
|
||||
#include "tests.h"
|
||||
|
||||
static int foo = 0;
|
||||
static int bar = 0;
|
||||
static int baz = 0;
|
||||
static char* memory = NULL;
|
||||
|
||||
static void test_destroy(int *b) {
|
||||
(*b)++;
|
||||
}
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(foo, test_destroy);
|
||||
STATIC_DESTRUCTOR_REGISTER(bar, test_destroy);
|
||||
STATIC_DESTRUCTOR_REGISTER(bar, test_destroy);
|
||||
STATIC_DESTRUCTOR_REGISTER(baz, test_destroy);
|
||||
STATIC_DESTRUCTOR_REGISTER(baz, test_destroy);
|
||||
STATIC_DESTRUCTOR_REGISTER(baz, test_destroy);
|
||||
STATIC_DESTRUCTOR_REGISTER(memory, freep);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
assert_se(memory = strdup("hallo"));
|
||||
|
||||
assert_se(foo == 0 && bar == 0 && baz == 0);
|
||||
static_destruct();
|
||||
assert_se(foo == 1 && bar == 2 && baz == 3);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user