bionic tests: switch to using android-base/file.h for TemporaryFile
A matching definition of TemporaryFile exists in libbase now.
Test: compile
Bug: 119313545
Change-Id: I6f84dbf3af9a9c4b270a2532a36c9cb4c0f6bb8f
diff --git a/tests/sys_xattr_test.cpp b/tests/sys_xattr_test.cpp
index 006e840..8f4a336 100644
--- a/tests/sys_xattr_test.cpp
+++ b/tests/sys_xattr_test.cpp
@@ -14,21 +14,21 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
-
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/xattr.h>
-#include "TemporaryFile.h"
+#include <android-base/file.h>
+#include <gtest/gtest.h>
TEST(sys_xattr, setxattr) {
TemporaryFile tf;
char buf[10];
- ASSERT_EQ(0, setxattr(tf.filename, "user.foo", "bar", 4, 0));
- ASSERT_EQ(4, getxattr(tf.filename, "user.foo", buf, sizeof(buf)));
+ ASSERT_EQ(0, setxattr(tf.path, "user.foo", "bar", 4, 0));
+ ASSERT_EQ(4, getxattr(tf.path, "user.foo", buf, sizeof(buf)));
ASSERT_STREQ("bar", buf);
buf[0] = '\0';
- ASSERT_EQ(4, lgetxattr(tf.filename, "user.foo", buf, sizeof(buf)));
+ ASSERT_EQ(4, lgetxattr(tf.path, "user.foo", buf, sizeof(buf)));
ASSERT_STREQ("bar", buf);
}
@@ -67,7 +67,7 @@
TEST(sys_xattr, fsetxattr_with_opath) {
TemporaryFile tf;
- int fd = open(tf.filename, O_PATH);
+ int fd = open(tf.path, O_PATH);
ASSERT_NE(-1, fd);
int res = fsetxattr(fd, "user.foo", "bar", 4, 0);
@@ -85,7 +85,7 @@
TEST(sys_xattr, fsetxattr_with_opath_toosmall) {
TemporaryFile tf;
- int fd = open(tf.filename, O_PATH);
+ int fd = open(tf.path, O_PATH);
ASSERT_NE(-1, fd);
int res = fsetxattr(fd, "user.foo", "01234567890123456789", 21, 0);
@@ -114,7 +114,7 @@
TemporaryFile tf;
char buf[65536]; // 64kB is max possible xattr list size. See "man 7 xattr".
ASSERT_EQ(0, fsetxattr(tf.fd, "user.foo", "bar", 4, 0));
- int fd = open(tf.filename, O_PATH);
+ int fd = open(tf.path, O_PATH);
ASSERT_NE(-1, fd);
ssize_t res = flistxattr(fd, buf, sizeof(buf));
#if defined(__BIONIC__)