Skip to content

Commit 36c91c7

Browse files
authored
Merge pull request betaflight#4243 from ledvinap/fix-atomic-unittest
Cleanup betaflight#2420
2 parents ceb6f70 + acedb46 commit 36c91c7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/test/Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Where to find user code.
1313
USER_DIR = ../main
14+
TEST_DIR = unit
1415

1516

1617
# specify which files that are included in the test in addition to the unittest file.
@@ -35,7 +36,7 @@ arming_prevention_unittest_SRC := \
3536
$(USER_DIR)/fc/runtime_config.c \
3637
$(USER_DIR)/common/bitarray.c
3738

38-
atomic_unittest_SRC = \
39+
atomic_unittest_SRC := \
3940
$(USER_DIR)/build/atomic.c \
4041
$(TEST_DIR)/atomic_unittest_c.c
4142

@@ -291,7 +292,6 @@ ringbuffer_unittest_SRC := \
291292
GTEST_DIR = ../../lib/test/gtest
292293

293294

294-
TEST_DIR = unit
295295
USER_INCLUDE_DIR = $(USER_DIR)
296296

297297
OBJECT_DIR = ../../obj/test
@@ -313,10 +313,14 @@ COMMON_FLAGS = \
313313
-ggdb3 \
314314
-O0 \
315315
-DUNIT_TEST \
316-
-fblocks \
317316
-isystem $(GTEST_DIR)/inc \
318317
-MMD -MP
319318

319+
ifeq ($(shell $(CC) -v 2>&1 | grep -q "clang version" && echo "clang"),clang)
320+
COMMON_FLAGS += -fblocks
321+
LDFLAGS += -lBlocksRuntime
322+
endif
323+
320324
ifneq ($(UNAME), Darwin)
321325
COMMON_FLAGS += -pthread
322326
endif
@@ -337,9 +341,9 @@ CXX_FLAGS += $(COVERAGE_FLAGS)
337341

338342
# Set up the parameter group linker flags according to OS
339343
ifeq ($(UNAME), Darwin)
340-
PG_FLAGS = -Wl,-map,$(OBJECT_DIR)/$@.map
344+
LDFLAGS += -Wl,-map,$(OBJECT_DIR)/$@.map
341345
else
342-
PG_FLAGS = -Wl,-T,$(TEST_DIR)/parameter_group.ld -Wl,-Map,$(OBJECT_DIR)/$@.map
346+
LDFLAGS += -Wl,-T,$(TEST_DIR)/parameter_group.ld -Wl,-Map,$(OBJECT_DIR)/$@.map
343347
endif
344348

345349
# Gather up all of the tests.
@@ -479,7 +483,7 @@ $(OBJECT_DIR)/$1/$1 : $$($$1_OBJS) \
479483

480484
@echo "linking $$@" "$(STDOUT)"
481485
$(V1) mkdir -p $(dir $$@)
482-
$(V1) $(CXX) $(CXX_FLAGS) $(PG_FLAGS) -lBlocksRuntime $$^ -o $$@
486+
$(V1) $(CXX) $(CXX_FLAGS) $(LDFLAGS) $$^ -o $$@
483487

484488
test_$1: $(OBJECT_DIR)/$1/$1
485489
$(V1) $$< $$(EXEC_OPTS) "$(STDOUT)" && echo "running $$@: PASS"

src/test/unit/atomic_unittest.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ TEST(AtomicUnittest, TestAtomicBlockNB)
6161
EXPECT_EQ(atomic_BASEPRI, 0); // restore priority to unlocked
6262
}
6363

64-
#if 1 // not working now ... (CLang needs -fblock + libraries / some unittests don't support gcc)
65-
6664
struct barrierTrace {
6765
int enter, leave;
6866
};
@@ -112,5 +110,3 @@ TEST(AtomicUnittest, TestAtomicBarrier)
112110
//return sIdx;
113111
EXPECT_EQ(sIdx, sampled);
114112
}
115-
116-
#endif

0 commit comments

Comments
 (0)