Skip to content

Commit

Permalink
Test case targets for T188746142
Browse files Browse the repository at this point in the history
Summary: This diff is to set up test cases that can be used to determine if classes are being kept as entry points when they have class names appearing in a file under META-INF/services directory in the input application.

Reviewed By: NTillmann

Differential Revision: D57521904

fbshipit-source-id: 943bf232d381196f00e220c1699f2bd3151d1f3d
  • Loading branch information
wsanville authored and facebook-github-bot committed May 20, 2024
1 parent 47095b9 commit 58721c6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
18 changes: 18 additions & 0 deletions test/instr/ApkReachableServiceLoaderVerify.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include <gtest/gtest.h>

#include "ReachableServiceLoaderVerifyImpl.h"

TEST_F(PreVerify, ApkReachableServiceLoaderTest) {
verify_exception_handlers_kept(classes);
}

TEST_F(PostVerify, ApkReachableServiceLoaderTest) {
// TODO: should have same classes as in pre-verify.
}
18 changes: 18 additions & 0 deletions test/instr/BundleReachableServiceLoaderVerify.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include <gtest/gtest.h>

#include "ReachableServiceLoaderVerifyImpl.h"

TEST_F(PreVerify, BundleReachableServiceLoaderTest) {
verify_exception_handlers_kept(classes);
}

TEST_F(PostVerify, BundleReachableServiceLoaderTest) {
// TODO: should have same classes as in pre-verify.
}
3 changes: 2 additions & 1 deletion test/instr/ReachableClasses.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"redex" : {
"passes" : [
"RemoveUnreachablePass"
"RemoveUnreachablePass",
"RegAllocPass"
]
}
}
24 changes: 24 additions & 0 deletions test/instr/ReachableServiceLoaderVerifyImpl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

#include <gtest/gtest.h>

#include "verify/VerifyUtil.h"

inline void verify_exception_handlers_kept(const DexClasses& classes) {
const char* const INTERFACE_NAME =
"Lkotlinx/coroutines/CoroutineExceptionHandler;";
const char* const IMPLEMENTATION_NAME =
"Lkotlinx/coroutines/android/AndroidExceptionPreHandler;";

auto iface = find_class_named(classes, INTERFACE_NAME);
EXPECT_NE(iface, nullptr) << "Did not find class " << INTERFACE_NAME;
auto cls = find_class_named(classes, IMPLEMENTATION_NAME);
EXPECT_NE(cls, nullptr) << "Did not find class " << IMPLEMENTATION_NAME;
}

0 comments on commit 58721c6

Please sign in to comment.