int main (int argc, char ** argv)
{
	printf ("YAJL       TESTS\n");
	printf ("==================\n\n");

	modules = ksNew (0, KS_END);
	elektraModulesInit (modules, 0);

	init (argc, argv);

	test_nextNotBelow ();
	test_reverseLevel ();
	test_countLevel ();
	test_writing ();

	test_json ("yajl/testdata_null.json", getNullKeys (), ksNew (0, KS_END));
	test_json ("yajl/testdata_boolean.json", getBooleanKeys (), ksNew (0, KS_END));
	test_json ("yajl/testdata_number.json", getNumberKeys (), ksNew (0, KS_END));
	test_json ("yajl/testdata_string.json", getStringKeys (), ksNew (0, KS_END));
	test_json ("yajl/testdata_maps.json", getMapKeys (), ksNew (0, KS_END));
	test_json ("yajl/testdata_array.json", getArrayKeys (), ksNew (0, KS_END));
	test_json ("yajl/testdata_below.json", getBelowKeys (), ksNew (0, KS_END));
	test_json ("yajl/OpenICC_device_config_DB.json", getOpenICCKeys (), ksNew (0, KS_END));

	// TODO currently do not have a KeySet, wait for C-plugin to make
	// it easy to generate it..
	test_readWrite ("yajl/empty_object.json", ksNew (0, KS_END));
	test_readWrite ("yajl/empty_array.json", ksNew (0, KS_END));
	test_readWrite ("yajl/top_level_string.json", ksNew (0, KS_END));
	test_readWrite ("yajl/top_level_integer.json", ksNew (0, KS_END));
	test_readWrite ("yajl/rfc_object.json", ksNew (0, KS_END));
	test_readWrite ("yajl/rfc_array.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_mixed.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_in_array.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_in_array_anon_map.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_nested.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_broken.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_special_ending.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_outside.json", ksNew (0, KS_END));
	test_readWrite ("yajl/keyframes_complex.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_mixed2.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_special_start.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_array_mixed3.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_empty_in_array.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_empty_in_map.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_empty_in_array1.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_empty_in_map2.json", ksNew (0, KS_END));
	test_readWrite ("yajl/testdata_empty_in_map1.json", ksNew (0, KS_END));

	elektraModulesClose (modules, 0);
	ksDel (modules);

	print_result ("test_yajl");

	return nbError;
}
Beispiel #2
0
void run_writing(int argc, char **argv)
{
    if(argc < 4){
        fprintf(stderr, "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n", argv[0], argv[1]);
        return;
    }

    char *cfg = argv[3];
    char *weights = (argc > 4) ? argv[4] : 0;
    char *filename = (argc > 5) ? argv[5] : 0;
    if(0==strcmp(argv[2], "train")) train_writing(cfg, weights);
    else if(0==strcmp(argv[2], "test")) test_writing(cfg, weights, filename);
}
Beispiel #3
0
/*
 * Do black box io testing on a sparse disk
 */
static void test_device_io( const char *device_name,
  const uint32_t                        block_size,
  const uint32_t                        media_block_size,
  const rtems_blkdev_bnum               block_number,
  const rtems_blkdev_bnum               blocks_allocated,
  const uint8_t                         fill_pattern )
{
  int rv;
  int file_descriptor;


  file_descriptor = open( device_name, O_RDWR );
  rtems_test_assert( 0 <= file_descriptor );

  test_disk_params(
    file_descriptor,
    block_size,
    media_block_size,
    block_number
    );

  test_writing(
    file_descriptor,
    block_size,
    blocks_allocated
    );

  test_reading(
    file_descriptor,
    block_size,
    blocks_allocated,
    fill_pattern
    );

  rv = close( file_descriptor );
  rtems_test_assert( 0 == rv );
}
Beispiel #4
0
/*
 * Read write testing with a statically allocated disk. Thus white box testing can be done
 */
static void test_with_whitebox( const char *device_name )
{
  rtems_status_code     sc;
  int                   rv;
  unsigned int          i;
  sparse_disk_container disk_container;
  int                   file_descriptor;
  rtems_blkdev_bnum     block_count  = 0;
  unsigned int          byte_count;
  uint8_t               fill_pattern = 0;


  memset( disk_container.data, 0, sizeof( disk_container.data ) );
  memset( disk_container.keytable, 0, sizeof( disk_container.keytable ) );

  for ( i = 0; i < STATIC_PATTERN_SIZE; ++i )
    disk_container.pattern[i] = (uint8_t) ( STATIC_PATTERN_SIZE - 1 - i );

  sc = rtems_sparse_disk_register(
    "/dev/sda1",
    &disk_container.sparse_disk,
    STATIC_BLOCK_SIZE,
    STATIC_ALLOCATED_BLOCK_COUNT,
    STATIC_SIMULATED_BLOCK_COUNT,
    fill_pattern,
    NULL
    );
  rtems_test_assert( RTEMS_SUCCESSFUL == sc );

  test_static_key_table(
    &disk_container,
    STATIC_ALLOCATED_BLOCK_COUNT,
    STATIC_BLOCK_SIZE
    );

  for ( i = 0; i < ( STATIC_BLOCK_SIZE * STATIC_ALLOCATED_BLOCK_COUNT ); ++i )
    rtems_test_assert( 0 == disk_container.data[i] );

  test_static_pattern(
    STATIC_PATTERN_SIZE,
    &disk_container.pattern[0]
    );

  file_descriptor = open( device_name, O_RDWR );
  rtems_test_assert( 0 <= file_descriptor );

  test_disk_params(
    file_descriptor,
    STATIC_BLOCK_SIZE,
    STATIC_BLOCK_SIZE,
    STATIC_SIMULATED_BLOCK_COUNT
    );

  test_writing(
    file_descriptor,
    STATIC_BLOCK_SIZE,
    STATIC_ALLOCATED_BLOCK_COUNT
    );

  test_reading(
    file_descriptor,
    STATIC_BLOCK_SIZE,
    STATIC_ALLOCATED_BLOCK_COUNT,
    fill_pattern
    );

  rv = close( file_descriptor );
  rtems_test_assert( 0 == rv );

  test_static_key_table(
    &disk_container,
    STATIC_ALLOCATED_BLOCK_COUNT,
    STATIC_BLOCK_SIZE
    );

  for ( block_count = 0;
        block_count < STATIC_ALLOCATED_BLOCK_COUNT;
        block_count++ ) {
    for ( byte_count = 0;
          byte_count < ( STATIC_BLOCK_SIZE / sizeof( byte_count ) );
          byte_count++ ) {
      rv = memcmp( &disk_container.data[byte_count * sizeof( byte_count )],
                   &byte_count,
                   sizeof( byte_count ) );
      rtems_test_assert( 0 == rv );
    }
  }

  test_static_pattern(
    STATIC_PATTERN_SIZE,
    &disk_container.pattern[0]
    );
}