Dimitry Ivanov | 927877c | 2016-09-21 11:17:13 -0700 | [diff] [blame] | 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 | |
Dimitry Ivanov | 5b2cd3a | 2017-03-16 11:34:13 -0700 | [diff] [blame] | 22 | #include <android-base/file.h> |
| 23 | |
Dimitry Ivanov | 927877c | 2016-09-21 11:17:13 -0700 | [diff] [blame] | 24 | #include <string> |
| 25 | |
Christopher Ferris | 6d2c0bd | 2018-08-21 18:13:10 -0700 | [diff] [blame] | 26 | std::string GetTestlibRoot() { |
Chris Parsons | cab794c | 2020-06-15 18:22:10 -0400 | [diff] [blame] | 27 | // Typically the executable is /data/nativetest[64]/bionic-unit-tests/bionic-unit-tests, and the |
Colin Cross | badcb38 | 2021-09-24 17:49:58 -0700 | [diff] [blame] | 28 | // test libraries are in /data/nativetest[64]/bionic-unit-tests/bionic-loader-test-libs. |
| 29 | std::string path = android::base::GetExecutableDirectory(); |
Victor Khimenko | 65273fb | 2017-01-24 22:12:07 +0100 | [diff] [blame] | 30 | |
Dimitry Ivanov | 927877c | 2016-09-21 11:17:13 -0700 | [diff] [blame] | 31 | std::string out_path; |
Dimitry Ivanov | 5b2cd3a | 2017-03-16 11:34:13 -0700 | [diff] [blame] | 32 | if (!android::base::Realpath(path.c_str(), &out_path)) { |
Pirama Arumuga Nainar | cb4a7c8 | 2020-05-30 16:46:20 -0700 | [diff] [blame] | 33 | printf("Failed to get realpath for \"%s\"\n", path.c_str()); |
Victor Khimenko | 65273fb | 2017-01-24 22:12:07 +0100 | [diff] [blame] | 34 | abort(); |
Dimitry Ivanov | 927877c | 2016-09-21 11:17:13 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Dimitry Ivanov | 927877c | 2016-09-21 11:17:13 -0700 | [diff] [blame] | 37 | out_path += "/bionic-loader-test-libs"; |
Dimitry Ivanov | d0b5c3a | 2016-11-25 12:23:11 -0800 | [diff] [blame] | 38 | |
Dimitry Ivanov | 927877c | 2016-09-21 11:17:13 -0700 | [diff] [blame] | 39 | std::string real_path; |
Dimitry Ivanov | 5b2cd3a | 2017-03-16 11:34:13 -0700 | [diff] [blame] | 40 | if (!android::base::Realpath(out_path, &real_path)) { |
Pirama Arumuga Nainar | cb4a7c8 | 2020-05-30 16:46:20 -0700 | [diff] [blame] | 41 | printf("\"%s\": does not exists\n", out_path.c_str()); |
Dimitry Ivanov | 927877c | 2016-09-21 11:17:13 -0700 | [diff] [blame] | 42 | abort(); |
| 43 | } |
| 44 | |
| 45 | return real_path; |
| 46 | } |