Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Mar 2009 01:12:01 +0000 (UTC)
From:      Tim Kientzle <kientzle@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189468 - head/lib/libarchive/test
Message-ID:  <200903070112.n271C1x9033925@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kientzle
Date: Sat Mar  7 01:12:01 2009
New Revision: 189468
URL: http://svn.freebsd.org/changeset/base/189468

Log:
  Merge the rest of r453 from libarchive.googlecode.com:  Test using
  libarchive APIs to read extended attributes from disk on FreeBSD.

Modified:
  head/lib/libarchive/test/test_extattr_freebsd.c

Modified: head/lib/libarchive/test/test_extattr_freebsd.c
==============================================================================
--- head/lib/libarchive/test/test_extattr_freebsd.c	Sat Mar  7 01:08:16 2009	(r189467)
+++ head/lib/libarchive/test/test_extattr_freebsd.c	Sat Mar  7 01:12:01 2009	(r189468)
@@ -41,6 +41,9 @@ DEFINE_TEST(test_extattr_freebsd)
 	skipping("extattr restore supported only on FreeBSD 5.0 and later");
 #else
 	char buff[64];
+	const char *xname;
+	const void *xval;
+	size_t xsize;
 	struct stat st;
 	struct archive *a;
 	struct archive_entry *ae;
@@ -150,5 +153,21 @@ DEFINE_TEST(test_extattr_freebsd)
 			assertEqualString(buff, "123456");
 		}
 	}
+
+	/* Use libarchive APIs to read the file back into an entry and
+	 * verify that the extattr was read correctly. */
+	assert((a = archive_read_disk_new()) != NULL);
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_set_pathname(ae, "test0");
+	assertEqualInt(ARCHIVE_OK,
+	    archive_read_disk_entry_from_file(a, ae, -1, NULL));
+	assertEqualInt(1, archive_entry_xattr_reset(ae));
+	assertEqualInt(ARCHIVE_OK,
+	    archive_entry_xattr_next(ae, &xname, &xval, &xsize));
+	assertEqualString(xname, "user.foo");
+	assertEqualInt(xsize, 5);
+	assertEqualMem(xval, "12345", xsize);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
 #endif
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903070112.n271C1x9033925>