diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2016-08-15 21:24:50 +0000 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2016-08-15 21:24:50 +0000 |
commit | ced79280697ca4661e36c957f47046cbde124029 (patch) | |
tree | cac19c994e7c2d9a995d2b4c63e99fed757eaa65 /libcxx/test/std/experimental/filesystem | |
parent | 28fdc4272d598bdb7b0696ac22c20e9a41836c03 (diff) | |
download | bcm5719-llvm-ced79280697ca4661e36c957f47046cbde124029.tar.gz bcm5719-llvm-ced79280697ca4661e36c957f47046cbde124029.zip |
libcxx: Fix path.compare.pass expected result
The expected 'filesystem::path::compare' result states that for different
path only result sign contains the information about passed arguments
(not its integer value). This is due it uses the output of other compare
functions (basic_string_view and char_traits) without further handling and
char_traits uses memcmp for final buffer comparison.
However for GLIBC on AArch64 the code:
int ret = memcmp ("b/a/c", "a/b/c", 1);
Results in '64' where for x86_64 it results in '1'.
This patch fixes the expected 'filesystem::path::compare' by normalizing
all the results before assert comparison.
llvm-svn: 278745
Diffstat (limited to 'libcxx/test/std/experimental/filesystem')
-rw-r--r-- | libcxx/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp index 64f57f13fb2..69d08e6eb49 100644 --- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp +++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp @@ -73,6 +73,11 @@ const PathCompareTest CompareTestCases[] = #undef LONGC #undef LONGD +static inline int normalize_ret(int ret) +{ + return ret < 0 ? -1 : (ret > 0 ? 1 : 0); +} + int main() { using namespace fs; @@ -86,13 +91,12 @@ int main() DisableAllocationGuard g; // none of these operations should allocate // check runtime results - int ret1 = p1.compare(p2); - int ret2 = p1.compare(R); - int ret3 = p1.compare(TC.RHS); - int ret4 = p1.compare(RV); + int ret1 = normalize_ret(p1.compare(p2)); + int ret2 = normalize_ret(p1.compare(R)); + int ret3 = normalize_ret(p1.compare(TC.RHS)); + int ret4 = normalize_ret(p1.compare(RV)); assert(ret1 == ret2 && ret1 == ret3 && ret1 == ret4); - int normalized_ret = ret1 < 0 ? -1 : (ret1 > 0 ? 1 : 0); - assert(normalized_ret == E); + assert(ret1 == E); // check signatures ASSERT_NOEXCEPT(p1.compare(p2)); |