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 18namespace 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(acos) \ 25 X(sin) \ 26 X(tan) 27 28#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBM_SYMBOLS_CLASS_NAME 29#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBM_SYMBOLS_LIST 30#include "webrtc/base/latebindingsymboltable.h.def" 31 32#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBM_SYMBOLS_CLASS_NAME 33#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBM_SYMBOLS_LIST 34#define LATE_BINDING_SYMBOL_TABLE_DLL_NAME "libm.so.6" 35#include "webrtc/base/latebindingsymboltable.cc.def" 36 37TEST(LateBindingSymbolTable, libm) { 38 LibmTestSymbolTable table; 39 EXPECT_FALSE(table.IsLoaded()); 40 ASSERT_TRUE(table.Load()); 41 EXPECT_TRUE(table.IsLoaded()); 42 EXPECT_EQ(table.acos()(0.5), acos(0.5)); 43 EXPECT_EQ(table.sin()(0.5), sin(0.5)); 44 EXPECT_EQ(table.tan()(0.5), tan(0.5)); 45 // It would be nice to check that the addresses are the same, but the nature 46 // of dynamic linking and relocation makes them actually be different. 47 table.Unload(); 48 EXPECT_FALSE(table.IsLoaded()); 49} 50 51#else 52#error Not implemented 53#endif 54 55} // namespace rtc 56