-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: internal: added cpu byte order test cases
Signed-off-by: Leonardo Alminana <[email protected]>
- Loading branch information
1 parent
7e2f3f0
commit 89f9931
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ set(UNIT_TESTS_FILES | |
processor.c | ||
uri.c | ||
msgpack_append_message.c | ||
endianness | ||
) | ||
|
||
# Config format | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
|
||
#include <fluent-bit/flb_info.h> | ||
#include <fluent-bit/flb_endian.h> | ||
|
||
#include "flb_tests_internal.h" | ||
|
||
/* This test case sets a specific value to a variable and compares | ||
* the memory representation against the byte order detected by | ||
* cmake. | ||
*/ | ||
static void flb_test_endianness_detection() | ||
{ | ||
volatile uint64_t source_value; | ||
volatile uint8_t *test_value; | ||
|
||
/* ~TEA, COFFEE */ | ||
source_value = 0x08140C0FFEE; | ||
test_value = (volatile uint8_t *) &source_value; | ||
|
||
#if FLB_BYTE_ORDER == FLB_LITTLE_ENDIAN | ||
TEST_CHECK(test_value[0] == 0xEE); | ||
#else | ||
TEST_CHECK(test_value[0] != 0xEE); | ||
#endif | ||
} | ||
|
||
TEST_LIST = { | ||
{ "test_endianness_detection", flb_test_endianness_detection }, | ||
|
||
{ 0 } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters