blob: 11b2dffe2a987e25d4dfe0be7c9fee7ef6b67fba [file] [log] [blame]
Dimitry Ivanov927877c2016-09-21 11:17:13 -07001/*
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 Ivanov5b2cd3a2017-03-16 11:34:13 -070022#include <android-base/file.h>
23
Dimitry Ivanov927877c2016-09-21 11:17:13 -070024#include <string>
25
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -070026std::string GetTestlibRoot() {
Chris Parsonscab794c2020-06-15 18:22:10 -040027 // Typically the executable is /data/nativetest[64]/bionic-unit-tests/bionic-unit-tests, and the
Colin Crossbadcb382021-09-24 17:49:58 -070028 // test libraries are in /data/nativetest[64]/bionic-unit-tests/bionic-loader-test-libs.
29 std::string path = android::base::GetExecutableDirectory();
Victor Khimenko65273fb2017-01-24 22:12:07 +010030
Dimitry Ivanov927877c2016-09-21 11:17:13 -070031 std::string out_path;
Dimitry Ivanov5b2cd3a2017-03-16 11:34:13 -070032 if (!android::base::Realpath(path.c_str(), &out_path)) {
Pirama Arumuga Nainarcb4a7c82020-05-30 16:46:20 -070033 printf("Failed to get realpath for \"%s\"\n", path.c_str());
Victor Khimenko65273fb2017-01-24 22:12:07 +010034 abort();
Dimitry Ivanov927877c2016-09-21 11:17:13 -070035 }
36
Dimitry Ivanov927877c2016-09-21 11:17:13 -070037 out_path += "/bionic-loader-test-libs";
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -080038
Dimitry Ivanov927877c2016-09-21 11:17:13 -070039 std::string real_path;
Dimitry Ivanov5b2cd3a2017-03-16 11:34:13 -070040 if (!android::base::Realpath(out_path, &real_path)) {
Pirama Arumuga Nainarcb4a7c82020-05-30 16:46:20 -070041 printf("\"%s\": does not exists\n", out_path.c_str());
Dimitry Ivanov927877c2016-09-21 11:17:13 -070042 abort();
43 }
44
45 return real_path;
46}