• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2010 The WebRTC Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)
12 #include <math.h>
13 #endif
14 
15 #include "webrtc/base/gunit.h"
16 #include "webrtc/base/latebindingsymboltable.h"
17 
18 namespace rtc {
19 
20 #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)
21 
22 #define LIBM_SYMBOLS_CLASS_NAME LibmTestSymbolTable
23 #define LIBM_SYMBOLS_LIST \
24   X(acosf) \
25   X(sinf) \
26   X(tanf)
27 
28 
29 #define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBM_SYMBOLS_CLASS_NAME
30 #define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBM_SYMBOLS_LIST
31 #include "webrtc/base/latebindingsymboltable.h.def"
32 
33 #define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBM_SYMBOLS_CLASS_NAME
34 #define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBM_SYMBOLS_LIST
35 #define LATE_BINDING_SYMBOL_TABLE_DLL_NAME "libm.so.6"
36 #include "webrtc/base/latebindingsymboltable.cc.def"
37 
TEST(LateBindingSymbolTable,libm)38 TEST(LateBindingSymbolTable, libm) {
39   LibmTestSymbolTable table;
40   EXPECT_FALSE(table.IsLoaded());
41   ASSERT_TRUE(table.Load());
42   EXPECT_TRUE(table.IsLoaded());
43   EXPECT_EQ(table.acosf()(0.5f), acosf(0.5f));
44   EXPECT_EQ(table.sinf()(0.5f), sinf(0.5f));
45   EXPECT_EQ(table.tanf()(0.5f), tanf(0.5f));
46   // It would be nice to check that the addresses are the same, but the nature
47   // of dynamic linking and relocation makes them actually be different.
48   table.Unload();
49   EXPECT_FALSE(table.IsLoaded());
50 }
51 
52 #else
53 #error Not implemented
54 #endif
55 
56 }  // namespace rtc
57