aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-12-03 15:21:17 -0800
committerDan Albert <danalbert@google.com>2015-12-03 15:21:17 -0800
commit730386f73444e5438aef1eb2aaf828ca68b909a3 (patch)
treed4f9cc16ae7cce21a684dcfb2c72277658c3416f /tests
parent82fa5582ebe11754082ecbdf476dbb81ac7d34be (diff)
downloadndk-730386f73444e5438aef1eb2aaf828ca68b909a3.tar.gz
Fix getcwd use to work on old devices.
Apparently not all versions of Android supported the getcwd(3) extension of mallocing memory when passed NULL, so this would create the string "(null)/libbar.so" on JB. Change-Id: I0174762c53337577a25893402fe74ae3481539f5
Diffstat (limited to 'tests')
-rw-r--r--tests/device/whole-static-libs/jni/main.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/device/whole-static-libs/jni/main.c b/tests/device/whole-static-libs/jni/main.c
index 67a4bc775..f4a3317eb 100644
--- a/tests/device/whole-static-libs/jni/main.c
+++ b/tests/device/whole-static-libs/jni/main.c
@@ -9,10 +9,16 @@
int main(int argc, char *argv[])
{
- void* lib;
+ char cwd[PATH_MAX];
+ if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ perror("getcwd");
+ return 1;
+ }
+
char buf[PATH_MAX];
- sprintf(buf, "%s/libbar.so", getcwd(NULL, 0));
- lib = dlopen(buf, RTLD_NOW);
+ sprintf(buf, "%s/libbar.so", cwd);
+
+ void* lib = dlopen(buf, RTLD_NOW);
if (lib == NULL) {
fprintf(stderr, "Could not dlopen(\"libbar.so\"): %s\n", dlerror());
return 1;