示例#1
0
文件: init.c 项目: greenmeent/rtems
void test_untar_from_memory(void)
{
  rtems_status_code sc;
  rtems_printer     printer;

  rtems_print_printer_printf(&printer);

  printf("Untaring from memory - ");
  sc = Untar_FromMemory_Print((void *)TARFILE_START, TARFILE_SIZE, &printer);
  if (sc != RTEMS_SUCCESSFUL) {
    printf ("error: untar failed: %s\n", rtems_status_text (sc));
    exit(1);
  }
  printf ("successful\n");

  /******************/
  printf( "========= /home/test_file =========\n" );
  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 );

}
示例#2
0
void test_untar_unzip_txz(void)
{
#if HAVE_XZ
  int status;
  rtems_printer     printer;
  int rv;
  Untar_XzChunkContext ctx;
  size_t i = 0;
  char *buffer = (char *)TARFILE_XZ_START;
  size_t buflen = TARFILE_XZ_SIZE;
  char inflate_buffer;

  puts( "" );

  rtems_test_assert( buflen != 0 );

  rtems_print_printer_printf(&printer);

  /* make a directory to untar it into */
  rv = mkdir( "/dest4", 0777 );
  rtems_test_assert( rv == 0 );

  rv = chdir( "/dest4" );
  rtems_test_assert( rv == 0 );

  printf( "Untaring chunks from txz - " );

  /*
   * Use 8K dict, this is set on the command line of xz when compressing.
   */
  status = Untar_XzChunkContext_Init(&ctx, XZ_DYNALLOC,
                                     8 * 1024, &inflate_buffer, 1);
  rtems_test_assert(status == UNTAR_SUCCESSFUL);
  for(i = 0; i < buflen; i++) {
    status = Untar_FromXzChunk_Print(&ctx, &buffer[i], 1, &printer);
    rtems_test_assert(status == UNTAR_SUCCESSFUL);
  }
  printf( "successful\n" );

  /******************/
  printf( "========= /dest4/home/test_file =========\n" );
  test_cat( "/dest4/home/test_file", 0, 0 );

  /******************/
  printf( "========= /dest4/home/test_script =========\n" );
  test_cat( "/dest4/home/test_script", 0, 0 );
  test_untar_check_mode("/dest4/home/test_script", 0755);

  /******************/
  printf( "========= /dest4/symlink =========\n" );
  test_cat( "/dest4/symlink", 0, 0 );
#endif
}
示例#3
0
文件: main.c 项目: jwalle/libASM
/*
void	test_putstr(void)
{
	char	str[] = "PUTSTR";
	printf("\033[1;33m%s\033[0m\n", str);
	ft_putstr("Bonjour");
	ft_putstr(" les");
	ft_putstr(" amis");
	ft_putstr(" !");
	ft_putstr("\n");
	ft_putstr(NULL);
	ft_putstr("\n");
	printf("\033[1;32m%s passed.\033[0m\n\n", str);
}

void	test_add(void)
{
//This function adds i & j
	char	str[] = "ADD";

	printf("\033[1;33m%s\033[0m\n", str);
	printf("3 + 5 = %d\n", ft_add(3, 5));
	printf("39 + 39 = %d\n", ft_add(39, 39));
	printf("0 + 0 = %d\n", ft_add(0, 0));
	printf("0 + (-100) = %d\n", ft_add(0, -100));
	printf("\033[1;32m%s passed.\033[0m\n\n", str);
}

void	test_mult(void)
{
//This function multiplies i & j
	char	str[] = "MULT";

	printf("\033[1;33m%s\033[0m\n", str);
	printf("3 * 5 = %d\n", ft_mult(3, 5));
	printf("39 * 39 = %d\n", ft_mult(39, 39));
	printf("-3 * -1000 = %d\n", ft_mult(-3, -1000));
	printf("0 * (-100) = %d\n", ft_mult(0, -100));
	printf("\033[1;32m%s passed.\033[0m\n\n", str);
}

void	test_putstr_fd(void)
{
	char	str[] = "PUTSTR_FD";
	printf("\033[1;33m%s\033[0m\n", str);
	ft_putstr_fd("Bonjour", 2);
	ft_putstr_fd(" les", 1);
	ft_putstr_fd(" amis", 2);
	ft_putstr_fd(" !", 1);
	ft_putstr_fd("\n", 3);
	ft_putstr_fd(NULL, 1);
	ft_putstr_fd("\n", 1);
	printf("\033[1;32m%s passed.\033[0m\n\n", str);
}

void	test_strclr(void)
{
	char	str[] = "STRCLR";
	char	str1[] = "COUCOU";
	char	str2[] = "LES";
	printf("\033[1;33m%s\033[0m\n", str);
	
	printf("%s et %s deviennent :  \n", str1, str2);
	ft_strclr(str1);
	ft_strclr(str2);
	printf("%s et %s\n", str1, str2);
	printf("\033[1;32m%s passed.\033[0m\n\n", str);
}
*/
int		main(void)
{
	test_isascii();
	test_isdigit();
	test_isalpha();
	test_isalnum();
	test_isprint();
	test_bzero();
	//test_toupper();
	//test_tolower();
	test_strlen();
	test_strcat();
	test_memset();
	test_memcpy();
	test_puts();
	test_strdup();
	test_cat();
	printf("\n\n\033[1;32m  !!  BONUS  !!  \033[0m\n\n");
	//test_putstr();
	//test_add();
	//test_mult();
	//test_putstr_fd();
	//test_strclr();
	test_strnew();
	test_putchar();
	return (0);
}
示例#4
0
int
main(void)
{
    test_equal();

    test_overflow();

    lzma_index *i = create_empty();
    test_many(i);
    lzma_index_end(i, NULL);

    i = create_small();
    test_many(i);
    lzma_index_end(i, NULL);

    i = create_big();
    test_many(i);
    lzma_index_end(i, NULL);

    test_cat();

    test_locate();

    test_corrupt();

    return 0;
}
示例#5
0
int main(int argc, char *argv[])
{
	TEST_START();
	TEST(test_cat());
	TEST_END();
	return 0;
}
示例#6
0
void test_untar_unzip_tgz(void)
{
  int status;
  rtems_printer     printer;
  int rv;
  Untar_GzChunkContext ctx;
  size_t i = 0;
  char *buffer = (char *)TARFILE_GZ_START;
  size_t buflen = TARFILE_GZ_SIZE;
  char inflate_buffer;

  puts( "" );

  rtems_test_assert( buflen != 0 );

  rtems_print_printer_printf(&printer);

  /* make a directory to untar it into */
  rv = mkdir( "/dest3", 0777 );
  rtems_test_assert( rv == 0 );

  rv = chdir( "/dest3" );
  rtems_test_assert( rv == 0 );

  printf( "Untaring chunks from tgz - " );

  status = Untar_GzChunkContext_Init(&ctx, &inflate_buffer, 1);
  rtems_test_assert(status == UNTAR_SUCCESSFUL);
  for(i = 0; i < buflen; i++) {
    status = Untar_FromGzChunk_Print(&ctx, &buffer[i], 1, &printer);
    rtems_test_assert(status == UNTAR_SUCCESSFUL);
  }
  printf( "successful\n" );

  /******************/
  printf( "========= /dest3/home/test_file =========\n" );
  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 );
}
示例#7
0
void test_untar_from_file(void)
{
  int                fd;
  int                rv;
  ssize_t            n;

  puts( "" );

  puts( "Copy tar image to test.tar" );
  /* Copy tar image from object to file in IMFS */
  fd = open( "/test.tar", O_CREAT|O_TRUNC|O_WRONLY, 0777 );
  rtems_test_assert( fd != -1 );

  n = write( fd, TARFILE_START, TARFILE_SIZE );
  rtems_test_assert( n == TARFILE_SIZE );
  close( fd );

  /* make a directory to untar it into */
  rv = mkdir( "/dest", 0777 );
  rtems_test_assert( rv == 0 );

  rv = chdir( "/dest" );
  rtems_test_assert( rv == 0 );

  /* Untar it */
  rv = Untar_FromFile( "/test.tar" );
  printf("Untaring from file - ");
  if (rv != UNTAR_SUCCESSFUL) {
    printf ("error: untar failed: %i\n", rv);
    exit(1);
  }
  printf ("successful\n");

  /******************/
  printf( "========= /dest/home/test_file =========\n" );
  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 );
}
示例#8
0
void test_untar_chunks_from_memory(void)
{
  rtems_status_code sc;
  rtems_printer     printer;
  int rv;
  Untar_ChunkContext ctx;
  unsigned long counter = 0;
  char *buffer = (char *)TARFILE_START;
  size_t buflen = TARFILE_SIZE;

  puts( "" );

  rtems_print_printer_printf(&printer);

  /* make a directory to untar it into */
  rv = mkdir( "/dest2", 0777 );
  rtems_test_assert( rv == 0 );

  rv = chdir( "/dest2" );
  rtems_test_assert( rv == 0 );

  printf( "Untaring chunks from memory - " );
  Untar_ChunkContext_Init(&ctx);
  do {
    sc = Untar_FromChunk_Print(&ctx, &buffer[counter], (size_t)1 , &printer);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    counter ++;
  } while (counter < buflen);
  printf("successful\n");

  /******************/
  printf( "========= /dest2/home/test_file =========\n" );
  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 );

}
示例#9
0
文件: tests.c 项目: dbhoekman/CS360
int runTests()
{
	int passed = 1;
	char newchar;
  passed &= lsTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
	passed &= test_cat();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
	passed &= test_read();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
	passed &= test_write();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= cdTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= chmodTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= mkdirTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= touchTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= linkTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= rmdirTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= pwdTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= cpTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= mvTest();
	printf("\nEnter a char to continue!\n");
	scanf(" %c", &newchar);
  passed &= lseekTest();

	if (passed == 1)
	{
		printf("\n\nEVERYTHING PASSED\n\n");
	}
	else
	{
		printf("\n\nNOT EVERYTHING PASSED\n\n");
	}
}
示例#10
0
文件: init.c 项目: 0871087123/rtems
void test_tarfs_load(void)
{
  rtems_status_code sc;

  printf("Loading tarfs image ... ");
  sc = rtems_tarfs_load("/",(void *)TARFILE_START, TARFILE_SIZE);
  if (sc != RTEMS_SUCCESSFUL) {
    printf ("error: untar failed: %s\n", rtems_status_text (sc));
    exit(1);
  }
  printf ("successful\n");

  /******************/
  printf( "========= /home/test_file =========\n" );
  test_cat( "/home/test_file", 0, 0 );
  
  /******************/
  puts("*** Skipping symlink -- NOT CURRENTLY SUPPORTED ***" );
#if 0
  printf( "========= /symlink =========\n" );
  test_cat( "/symlink", 0, 0 );
#endif
}
示例#11
0
文件: main.c 项目: ptitmax/42
int main()
{
	test_isalpha();
	test_isdigit();
	test_isalnum();
	test_isascii();
	test_isprint();
	test_tolower();
	test_toupper();
	test_bzero();
	test_strcat();
	test_strlen();
	test_memset();
	test_memcpy();
	test_puts();
	test_strdup();
	test_strcmp();
	test_cat();
	test_isspace();
}
int
main(void)
{
	test_equal();

	test_overflow();

	lzma_index *i = create_empty();
	test_many(i);
	lzma_index_end(i, NULL);

	i = create_small();
	test_many(i);
	lzma_index_end(i, NULL);

	i = create_big();
	test_many(i);
	lzma_index_end(i, NULL);

	test_cat();

	test_locate();

	test_corrupt();

	// Test for the bug fix 21515d79d778b8730a434f151b07202d52a04611:
	// liblzma: Fix lzma_index_dup() for empty Streams.
	i = create_empty();
	expect(lzma_index_stream_padding(i, 4) == LZMA_OK);
	test_copy(i);
	lzma_index_end(i, NULL);

	// Test for the bug fix 3bf857edfef51374f6f3fffae3d817f57d3264a0:
	// liblzma: Fix a memory leak in error path of lzma_index_dup().
	// Use Valgrind to see that there are no leaks.
	i = create_small();
	expect(lzma_index_dup(i, &my_allocator) == NULL);
	lzma_index_end(i, NULL);

	return 0;
}
示例#13
0
int main(int argc, char *argv[])
{
	Animal animal;
	Bird bird, mutantBird;
	Cat cat;
	Crow crow;

	newAnimal(&animal);
	animal.setName(&animal, animalName);

	newBird(&bird);
	((Animal *) &bird)->setName((Animal *) &bird, birdName);

	newBird(&mutantBird);
	((Animal *) &mutantBird)->setName((Animal *) &mutantBird, mutantBirdName);
	((Animal *) &mutantBird)->setLegs((Animal *) &mutantBird, 3);

	newCat(&cat);
	((Animal *) &cat)->setName((Animal *) &cat, catsName);

	newCrow(&crow);
	((Animal *) &crow)->setName((Animal *) &crow, crowName);

	test_animal(&animal);
	test_animal((Animal *) &bird);
	test_animal((Animal *) &mutantBird);
	test_animal((Animal *) &cat);
	test_animal((Animal *) &crow);

	test_cat(&cat);

	test_bird(&bird);
	test_bird((Bird *) &mutantBird);
	test_bird((Bird *) &crow);

	test_crow(&crow);

	return 0;
}
示例#14
0
int main(int argc, char *argv[])
{
	test_cat();
}
示例#15
0
文件: main.c 项目: Taakh/LibftASM
int		main(void)
{
	printf("\n");

	printf ("\033[31m1 = Oui / 0 = Non\n\n\033[0m");
	
	printf("\033[33m=== FT_BZERO   ===\n\033[0m");

		test_bzero();
		printf("\n");
	
	printf("\033[33m=== FT_STRCAT  ===\n\033[0m");	
	
		test_strcat();
		printf("\n");

	printf("\033[33m=== FT_ISALPHA ===\n\033[0m");
	
		test_isalpha();
		printf("\n");

	printf("\033[33m=== FT_ISDIGIT ===\n\033[0m");
	
		test_isdigit();
		printf("\n");

	printf("\033[33m=== FT_ISALNUM ===\n\033[0m");
	
		test_isalnum();
		printf("\n");

	printf("\033[33m=== FT_ISASCII ===\n\033[0m");
	
		test_isascii();
		printf("\n");

	printf("\033[33m=== FT_ISPRINT ===\n\033[0m");

		test_isprint();
		printf("\n");
	printf("\033[33m=== FT_TOUPPER ===\n\033[0m");

		test_toupper();
		printf("\n");

	printf("\033[33m=== FT_TOLOWER ===\n\033[0m");

		test_tolower();
		printf("\n");

	printf("\033[33m=== FT_PUTS ===\n\033[0m");

		test_puts();
		printf("\n");

	printf("\033[33m=== FT_STRLEN ===\n\033[0m");

		test_strlen();
		printf("\n");

	printf("\033[33m=== FT_MEMSET ===\n\033[0m");	

		test_memset();
		printf("\n");

	printf("\033[33m=== FT_STRDUP ===\n\033[0m");

		test_strdup();
		printf("\n");

	printf("\033[33m=== FT_MEMCPY ===\n\033[0m");

		test_memcpy();
		printf("\n");
	
	printf("\033[33m=== FT_CAT ===\n\033[0m");

		test_cat();
		printf("\n");
	return (0);
}