source: rtems/testsuites/libtests/tar01/init.c @ a0b1b5ed

4.115
Last change on this file since a0b1b5ed was a0b1b5ed, checked in by Sebastian Huber <sebastian.huber@…>, on 12/15/14 at 13:19:43

Delete CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM

This define was superfluous, undocumented and used inconsistently.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <bsp.h> /* for device driver prototypes */
15#include "tmacros.h"
16#include <rtems/untar.h>
17#include <rtems/error.h>
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <fcntl.h>
24#include <unistd.h>
25
26#include "initial_filesystem_tar.h"
27
28const char rtems_test_name[] = "TAR 1";
29
30/* forward declarations to avoid warnings */
31rtems_task Init(rtems_task_argument argument);
32void test_untar_from_memory(void);
33void test_untar_from_file(void);
34
35#define TARFILE_START initial_filesystem_tar
36#define TARFILE_SIZE  initial_filesystem_tar_size
37
38void test_cat(
39  char *file,
40  int   offset_arg,
41  int   length
42);
43
44void test_untar_from_memory(void)
45{
46  rtems_status_code sc;
47
48  printf("Untaring from memory - ");
49  sc = Untar_FromMemory((void *)TARFILE_START, TARFILE_SIZE);
50  if (sc != RTEMS_SUCCESSFUL) {
51    printf ("error: untar failed: %s\n", rtems_status_text (sc));
52    exit(1);
53  }
54  printf ("successful\n");
55
56  /******************/
57  printf( "========= /home/test_file =========\n" );
58  test_cat( "/home/test_file", 0, 0 );
59 
60  /******************/
61  printf( "========= /symlink =========\n" );
62  test_cat( "/symlink", 0, 0 );
63
64}
65
66void test_untar_from_file(void)
67{
68  int                fd;
69  int                rv;
70  ssize_t            n;
71
72  puts( "Copy tar image to test.tar" );
73  /* Copy tar image from object to file in IMFS */
74  fd = open( "/test.tar", O_CREAT|O_TRUNC|O_WRONLY, 0777 );
75  rtems_test_assert( fd != -1 );
76
77  n = write( fd, TARFILE_START, TARFILE_SIZE );
78  rtems_test_assert( n == TARFILE_SIZE );
79  close( fd );
80
81  /* make a directory to untar it into */
82  rv = mkdir( "/dest", 0777 );
83  rtems_test_assert( rv == 0 );
84
85  rv = chdir( "/dest" );
86  rtems_test_assert( rv == 0 );
87
88  /* Untar it */
89  rv = Untar_FromFile( "/test.tar" );
90  printf("Untaring from file - ");
91  if (rv != UNTAR_SUCCESSFUL) {
92    printf ("error: untar failed: %i\n", rv);
93    exit(1);
94  }
95  printf ("successful\n");
96
97  /******************/
98  printf( "========= /dest/home/test_file =========\n" );
99  test_cat( "/dest/home/test_file", 0, 0 );
100 
101  /******************/
102  printf( "========= /dest/symlink =========\n" );
103  test_cat( "/dest/symlink", 0, 0 );
104}
105
106rtems_task Init(
107  rtems_task_argument ignored
108)
109{
110  TEST_BEGIN();
111
112  test_untar_from_memory();
113  puts( "" );
114  test_untar_from_file();
115
116  TEST_END();
117  exit( 0 );
118}
119
120
121/* NOTICE: the clock driver is explicitly disabled */
122#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
123#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
124
125#define CONFIGURE_MAXIMUM_TASKS            1
126#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
127
128#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
129
130#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
131
132#define CONFIGURE_INIT
133#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.