diff --git a/tests/ls/getxattr-speedup b/tests/ls/getxattr-speedup index f3dc5bb..9127a28 100755 --- a/tests/ls/getxattr-speedup +++ b/tests/ls/getxattr-speedup @@ -21,7 +21,8 @@ . "${srcdir=.}/init.sh"; path_prepend_ ../src print_ver_ ls -fd=33 +speeduptext="__SPEEDUP__" +speeduptextlen=$( echo "$speeduptext" | wc -c ) # also count newline. # Replace each getxattr and lgetxattr call with a call to these stubs. # Each writes a single line to the specified FD so that we can later @@ -32,29 +33,27 @@ cat > k.c <<'EOF' || framework_failure_ static void write_1 (void) { - int fd = @FD@; - write (fd, "x\n", 2); + write (1, SPEEDUPTEXT "\n", SPEEDUPTEXTLEN); } ssize_t getxattr (const char *path, const char *name, void *value, size_t size) { write_1 (); errno = ENOTSUP; return -1; } ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) { write_1 (); errno = ENOTSUP; return -1; } EOF -sed "s/@FD@/$fd/" k.c > k || framework_failure_ -mv k k.c || framework_failure_ # Then compile/link it: -$CC -fPIC -O2 -c k.c || framework_failure_ 'failed to compile with -fPIC' +$CC -DSPEEDUPTEXT="\"$speeduptext\"" -DSPEEDUPTEXTLEN="$speeduptextlen" \ + -fPIC -O2 -c k.c || framework_failure_ 'failed to compile with -fPIC' ld -G k.o -o k.so || framework_failure_ 'failed to invoke ld -G ...' # create a few files seq 100 | xargs touch || framework_failure_ # Finally, run the test, redirecting -eval "LD_PRELOAD=$PWD/k.so ls --color=always -l . $fd>x" || fail=1 +eval "LD_PRELOAD=$PWD/k.so ls --color=always -l . >x" || fail=1 # Ensure that there were no more than 3 *getxattr calls. -n_calls=$(wc -l < x) +n_calls=$( grep "^$speeduptext\$" x | wc -l) test "$n_calls" -le 3 || fail=1 Exit $fail