Fix ulimit in 151-OpenFileLimit
"adb shell" does not propagate the limit so this never worked on target.
Set the limit in the process itself so that it does work.
Test: Check that the tests throws exception early on all targets.
Change-Id: I4d7faaef4ab8165fdc1cd00cec8b6c0ce67e05b1
diff --git a/TEST_MAPPING b/TEST_MAPPING
index f75fb5d..ef22aa9 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -311,9 +311,6 @@
"name": "art-run-test-145-alloc-tracking-stress[com.google.android.art.apex]"
},
{
- "name": "art-run-test-151-OpenFileLimit[com.google.android.art.apex]"
- },
- {
"name": "art-run-test-152-dead-large-object[com.google.android.art.apex]"
},
{
@@ -1648,9 +1645,6 @@
"name": "art-run-test-145-alloc-tracking-stress"
},
{
- "name": "art-run-test-151-OpenFileLimit"
- },
- {
"name": "art-run-test-152-dead-large-object"
},
{
@@ -2979,9 +2973,6 @@
"name": "art-run-test-145-alloc-tracking-stress"
},
{
- "name": "art-run-test-151-OpenFileLimit"
- },
- {
"name": "art-run-test-152-dead-large-object"
},
{
diff --git a/test/151-OpenFileLimit/Android.bp b/test/151-OpenFileLimit/Android.bp
index 946be83..6b2a8c9 100644
--- a/test/151-OpenFileLimit/Android.bp
+++ b/test/151-OpenFileLimit/Android.bp
@@ -15,7 +15,7 @@
java_test {
name: "art-run-test-151-OpenFileLimit",
defaults: ["art-run-test-defaults"],
- test_config_template: ":art-run-test-target-template",
+ test_config_template: ":art-run-test-target-no-test-suite-tag-template",
srcs: ["src/**/*.java"],
data: [
":art-run-test-151-OpenFileLimit-expected-stdout",
diff --git a/test/151-OpenFileLimit/expected-stdout.txt b/test/151-OpenFileLimit/expected-stdout.txt
index 6bc45ef..18903be 100644
--- a/test/151-OpenFileLimit/expected-stdout.txt
+++ b/test/151-OpenFileLimit/expected-stdout.txt
@@ -1,3 +1,4 @@
+JNI_OnLoad called
Message includes "Too many open files"
thread run.
done.
diff --git a/test/151-OpenFileLimit/run.py b/test/151-OpenFileLimit/run.py
index 5e9f05a..61386aa 100644
--- a/test/151-OpenFileLimit/run.py
+++ b/test/151-OpenFileLimit/run.py
@@ -21,7 +21,4 @@
# Filter out expected error messages, which happen on device.
ctx.env.ANDROID_LOG_TAGS = "*:f"
- # Reduce the file descriptor limit so the test will reach the limit sooner.
- resource.setrlimit(resource.RLIMIT_NOFILE, (512, 512))
-
ctx.default_run(args, external_log_tags=True)
diff --git a/test/151-OpenFileLimit/src/Main.java b/test/151-OpenFileLimit/src/Main.java
index 9b16090..561c17a 100644
--- a/test/151-OpenFileLimit/src/Main.java
+++ b/test/151-OpenFileLimit/src/Main.java
@@ -24,6 +24,9 @@
private static final String TEMP_FILE_NAME_SUFFIX = ".txt";
public static void main(String[] args) throws IOException {
+ System.loadLibrary(args[0]);
+
+ setRlimitNoFile(512);
// Exhaust the number of open file descriptors.
List<File> files = new ArrayList<File>();
@@ -79,4 +82,6 @@
}
}
}
+
+ public static native void setRlimitNoFile(int value);
}
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index e0e9641..46f3828 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -18,6 +18,7 @@
#include <android-base/logging.h>
#include <android-base/macros.h>
+#include <sys/resource.h>
#include "art_field.h"
#include "art_method-inl.h"
@@ -463,4 +464,9 @@
Runtime::Current()->SetAsyncExceptionsThrown();
}
+extern "C" JNIEXPORT void JNICALL Java_Main_setRlimitNoFile(JNIEnv*, jclass, jint value) {
+ rlimit limit { static_cast<rlim_t>(value), static_cast<rlim_t>(value) };
+ setrlimit(RLIMIT_NOFILE, &limit);
+}
+
} // namespace art
diff --git a/test/utils/regen-test-files b/test/utils/regen-test-files
index 6c648fc..4315949 100755
--- a/test/utils/regen-test-files
+++ b/test/utils/regen-test-files
@@ -94,7 +94,6 @@
"1004-checker-volatile-ref-load",
"133-static-invoke-super",
"1338-gc-no-los",
- "151-OpenFileLimit",
"159-app-image-fields",
"160-read-barrier-stress",
"163-app-image-methods",