1//===- TestLinkerTest.cpp -------------------------------------------------===//
2//
3//                     The MCLinker Project
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#include "Linker/TestLinker.h"
10#include "TestLinkerTest.h"
11
12#include <mcld/Support/Path.h>
13#include <mcld/MC/MCLDDirectory.h>
14
15using namespace mcld;
16using namespace mcld::test;
17using namespace mcld::sys::fs;
18using namespace mcldtest;
19
20
21// Constructor can do set-up work for all test here.
22TestLinkerTest::TestLinkerTest()
23  : m_pLinker(NULL) {
24}
25
26// Destructor can do clean-up work that doesn't throw exceptions here.
27TestLinkerTest::~TestLinkerTest()
28{
29}
30
31// SetUp() will be called immediately before each test.
32void TestLinkerTest::SetUp()
33{
34  m_pLinker = new mcld::test::TestLinker();
35  m_pLinker->initialize("arm-none-linux-gnueabi");
36
37  // set up target-dependent constraints of attributes
38  m_pLinker->config()->attrFactory().constraint().enableWholeArchive();
39  m_pLinker->config()->attrFactory().constraint().disableAsNeeded();
40  m_pLinker->config()->attrFactory().constraint().setSharedSystem();
41
42  // set up the predefined attributes
43  m_pLinker->config()->attrFactory().predefined().setWholeArchive();
44  m_pLinker->config()->attrFactory().predefined().setDynamic();
45
46  // set up target dependent options
47  mcld::sys::fs::Path path = TOPDIR;
48  path.append("test/libs/ARM/Android/android-14");
49  m_pLinker->setSysRoot(path);
50  m_pLinker->addSearchDir("=/");
51
52  m_pLinker->config()->options().setDyld("/usr/lib/ld.so.1");
53  m_pLinker->config()->options().setBsymbolic(true);
54}
55
56// TearDown() will be called immediately after each test.
57void TestLinkerTest::TearDown()
58{
59  delete m_pLinker;
60}
61
62//===----------------------------------------------------------------------===//
63// Testcases
64//===----------------------------------------------------------------------===//
65TEST_F( TestLinkerTest, test) {
66  m_pLinker->config()->options().setVerbose(3);
67  mcld::sys::fs::Path top_level = TOPDIR;
68  m_pLinker->addObject(top_level + "test/libs/ARM/Android/android-14/crtbegin_so.o");
69  m_pLinker->addObject(top_level + "test/Android/Plasma/ARM/plasma.o");
70  m_pLinker->addNameSpec("m");
71  m_pLinker->addNameSpec("log");
72  m_pLinker->addNameSpec("jnigraphics");
73  m_pLinker->addNameSpec("c");
74  m_pLinker->addObject(top_level + "test/libs/ARM/Android/android-14/crtend_so.o");
75}
76
77