Update pacRunner utility to run proxy-resolution in loop Bug: 117556220 Bug: 129556445 Test: Ran the new testcase on android-8.0.0_r2 with/without patch Merged-In: If817b15b8e994bbbcf0ce19e00948cd8791e19d1 Change-Id: Ibd6b33acdbfa979878d05609ad3b0df0309dd4bf
diff --git a/hostsidetests/securitybulletin/securityPatch/pac/pac.cpp b/hostsidetests/securitybulletin/securityPatch/pac/pac.cpp index 393848d..0629ec3 100644 --- a/hostsidetests/securitybulletin/securityPatch/pac/pac.cpp +++ b/hostsidetests/securitybulletin/securityPatch/pac/pac.cpp
@@ -20,15 +20,22 @@ #include <codecvt> #include <fstream> #include <iostream> +#include "../includes/common.h" const char16_t* spec = u""; const char16_t* host = u""; int main(int argc, char *argv[]) { + bool shouldRunMultipleTimes = false; if (argc != 2) { - std::cout << "incorrect number of arguments" << std::endl; - std::cout << "usage: ./pacrunner mypac.pac" << std::endl; - return EXIT_FAILURE; + if (argc != 3) { + std::cout << "incorrect number of arguments" << std::endl; + std::cout << "usage: ./pacrunner mypac.pac (or)" << std::endl; + std::cout << "usage: ./pacrunner mypac.pac true" << std::endl; + return EXIT_FAILURE; + } else { + shouldRunMultipleTimes = true; + } } ProxyResolverV8Handle* handle = ProxyResolverV8Handle_new(); @@ -50,7 +57,10 @@ std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(u8Script); ProxyResolverV8Handle_SetPacScript(handle, u16Script.data()); - ProxyResolverV8Handle_GetProxyForURL(handle, spec, host); + time_t currentTime = start_timer(); + do { + ProxyResolverV8Handle_GetProxyForURL(handle, spec, host); + } while (shouldRunMultipleTimes && timer_active(currentTime)); ProxyResolverV8Handle_delete(handle); return EXIT_SUCCESS;
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java b/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java index 5d22ed1..a028330 100644 --- a/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java +++ b/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java
@@ -445,9 +445,24 @@ * @param device device to be ran on */ public static int runProxyAutoConfig(String pacName, ITestDevice device) throws Exception { + return runProxyAutoConfig(pacName, null, device); + } + + /** + * Runs the binary against a given proxyautoconfig file, asserting that it doesn't + * crash + * @param pacName the name of the proxy autoconfig script from the /res folder + * @param arguments input arguments for pacrunner + * @param device device to be ran on + */ + public static int runProxyAutoConfig(String pacName, String arguments, + ITestDevice device) throws Exception { pacName += ".pac"; String targetPath = TMP_PATH + pacName; AdbUtils.pushResource("/" + pacName, targetPath, device); + if(arguments != null) { + targetPath += " " + arguments; + } runPocAssertNoCrashes( "pacrunner", device, targetPath, new CrashUtils.Config().setProcessPatterns("pacrunner"));