summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/tar01/init.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-08-01 11:02:13 +1000
committerChris Johns <chrisj@rtems.org>2016-08-09 17:22:26 +1000
commitb0f08c83e23e69c7b19b04d38910f90b5f7af51b (patch)
tree260e3b5eb5323bcd5628d3269dcd96207f02ee4c /testsuites/libtests/tar01/init.c
parentbsp/atsam: Add power support (diff)
downloadrtems-b0f08c83e23e69c7b19b04d38910f90b5f7af51b.tar.bz2
libmisc/untar: Set the perms to the value in the tar file.
This patch parses the mode field in the tar header and sets the directory or file to the mode value in the header. Closes #2768.
Diffstat (limited to 'testsuites/libtests/tar01/init.c')
-rw-r--r--testsuites/libtests/tar01/init.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c
index 4bfa29c636..7d4f1b9a2a 100644
--- a/testsuites/libtests/tar01/init.c
+++ b/testsuites/libtests/tar01/init.c
@@ -46,6 +46,16 @@ void test_cat(
int length
);
+static void test_untar_check_mode(const char* file, int mode)
+{
+ struct stat sb;
+ int fmode;
+ rtems_test_assert(stat(file, &sb) == 0);
+ fmode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+ printf(" %s: mode: %04o want: %04o\n", file, fmode, mode);
+ rtems_test_assert(fmode == mode);
+}
+
void test_untar_from_memory(void)
{
rtems_status_code sc;
@@ -66,6 +76,11 @@ void test_untar_from_memory(void)
test_cat( "/home/test_file", 0, 0 );
/******************/
+ printf( "========= /home/test_script =========\n" );
+ test_cat( "/home/test_script", 0, 0 );
+ test_untar_check_mode("/home/test_script", 0755);
+
+ /******************/
printf( "========= /symlink =========\n" );
test_cat( "/symlink", 0, 0 );
@@ -107,6 +122,11 @@ void test_untar_from_file(void)
test_cat( "/dest/home/test_file", 0, 0 );
/******************/
+ printf( "========= /dest/home/test_script =========\n" );
+ test_cat( "/dest/home/test_script", 0, 0 );
+ test_untar_check_mode("/dest/home/test_script", 0755);
+
+ /******************/
printf( "========= /dest/symlink =========\n" );
test_cat( "/dest/symlink", 0, 0 );
}
@@ -144,6 +164,11 @@ void test_untar_chunks_from_memory(void)
test_cat( "/dest2/home/test_file", 0, 0 );
/******************/
+ printf( "========= /dest2/home/test_script =========\n" );
+ test_cat( "/dest2/home/test_script", 0, 0 );
+ test_untar_check_mode("/dest2/home/test_script", 0755);
+
+ /******************/
printf( "========= /dest2/symlink =========\n" );
test_cat( "/dest2/symlink", 0, 0 );
@@ -184,6 +209,11 @@ void test_untar_unzip_tgz(void)
test_cat( "/dest3/home/test_file", 0, 0 );
/******************/
+ printf( "========= /dest3/home/test_script =========\n" );
+ test_cat( "/dest3/home/test_script", 0, 0 );
+ test_untar_check_mode("/dest3/home/test_script", 0755);
+
+ /******************/
printf( "========= /dest3/symlink =========\n" );
test_cat( "/dest3/symlink", 0, 0 );
}