From 5d0843b7f20f03049ab2327991d104f3a03defe7 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Wed, 22 Jun 2022 20:27:15 +0000 Subject: [PATCH] Revert "connectivity_native_test: remove retries" This reverts commit ccde0db1740fe063465c2beccab518017ac502c5. Reason for revert: fails in mainline prod branch Change-Id: Id26c44b9e9c68a259d3c82d67a5f4cea27569432 --- tests/native/connectivity_native_test.cpp | 35 +++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/tests/native/connectivity_native_test.cpp b/tests/native/connectivity_native_test.cpp index 29b14ca430..3db5265f85 100644 --- a/tests/native/connectivity_native_test.cpp +++ b/tests/native/connectivity_native_test.cpp @@ -233,29 +233,54 @@ TEST_F(ConnectivityNativeBinderTest, UnblockAllPorts) { } TEST_F(ConnectivityNativeBinderTest, BlockNegativePort) { - ndk::ScopedAStatus status = mService->blockPortForBind(-1); + int retry = 0; + ndk::ScopedAStatus status; + do { + status = mService->blockPortForBind(-1); + // TODO: find out why transaction failed is being thrown on the first attempt. + } while (status.getExceptionCode() == EX_TRANSACTION_FAILED && retry++ < 5); EXPECT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } TEST_F(ConnectivityNativeBinderTest, UnblockNegativePort) { - ndk::ScopedAStatus status = mService->unblockPortForBind(-1); + int retry = 0; + ndk::ScopedAStatus status; + do { + status = mService->unblockPortForBind(-1); + // TODO: find out why transaction failed is being thrown on the first attempt. + } while (status.getExceptionCode() == EX_TRANSACTION_FAILED && retry++ < 5); EXPECT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } TEST_F(ConnectivityNativeBinderTest, BlockMaxPort) { - ndk::ScopedAStatus status = mService->blockPortForBind(65536); + int retry = 0; + ndk::ScopedAStatus status; + do { + status = mService->blockPortForBind(65536); + // TODO: find out why transaction failed is being thrown on the first attempt. + } while (status.getExceptionCode() == EX_TRANSACTION_FAILED && retry++ < 5); EXPECT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } TEST_F(ConnectivityNativeBinderTest, UnblockMaxPort) { - ndk::ScopedAStatus status = mService->unblockPortForBind(65536); + int retry = 0; + ndk::ScopedAStatus status; + do { + status = mService->unblockPortForBind(65536); + // TODO: find out why transaction failed is being thrown on the first attempt. + } while (status.getExceptionCode() == EX_TRANSACTION_FAILED && retry++ < 5); EXPECT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } TEST_F(ConnectivityNativeBinderTest, CheckPermission) { + int retry = 0; int curUid = getuid(); EXPECT_EQ(0, seteuid(FIRST_APPLICATION_UID + 2000)) << "seteuid failed: " << strerror(errno); - ndk::ScopedAStatus status = mService->blockPortForBind(5555); + ndk::ScopedAStatus status; + do { + status = mService->blockPortForBind(5555); + // TODO: find out why transaction failed is being thrown on the first attempt. + } while (status.getExceptionCode() == EX_TRANSACTION_FAILED && retry++ < 5); EXPECT_EQ(EX_SECURITY, status.getExceptionCode()); EXPECT_EQ(0, seteuid(curUid)) << "seteuid failed: " << strerror(errno); }