• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "gtest_globals.h"
18 
19 #include <gtest/gtest.h>
20 #include "utils.h"
21 
22 #include <android-base/file.h>
23 
24 #include <string>
25 
GetTestlibRoot()26 std::string GetTestlibRoot() {
27   // Calculate ANDROID_DATA assuming the binary is in "$ANDROID_DATA/somedir/binary-dir/binary"
28   std::string path = android::base::Dirname(android::base::GetExecutablePath()) + "/..";
29 
30   std::string out_path;
31   if (!android::base::Realpath(path.c_str(), &out_path)) {
32     printf("Failed to get realpath for \"%s\"", path.c_str());
33     abort();
34   }
35 
36   out_path += "/bionic-loader-test-libs";
37 
38   std::string real_path;
39   if (!android::base::Realpath(out_path, &real_path)) {
40     printf("\"%s\": does not exists", out_path.c_str());
41     abort();
42   }
43 
44   return real_path;
45 }
46