Example #1
0
int main(int argc, char **argv) {
    MPI_Init(&argc, &argv);
    adios_init("transforms.xml", comm);

    double *arr = malloc(N * sizeof(double));
    memset(arr, 123, N * sizeof(double));

    write_test_file(arr);
    read_test_file(arr);

    adios_finalize(0);
    MPI_Finalize();
}
Example #2
0
/**
 * @brief
 * Carga en la estructura AUDIO_FILE todo el contenido de un fichero PCM
 * Si el fichero no fuese PCM devuelve error
 *
 * @param param1 Ruta al fichero pcm.
 * @param param2 Estructura de audio.
 * @return WAV_ERROR_CODE si hay error, 0 si no hay problema
 * @note Something to note.
 * @warning Warning.
 */
int read_pcm_file(AUDIO_FILE* audio){
	#ifdef OUTFILE
		FILE* out;
		Limits num_limits;
	#endif
	uint8_t* sample_buffer;
	long i;
	unsigned int current_channel;
	int current_data;
	int error_code;


	#ifdef OUTFILE
	out = fopen("test.txt", "wb");
	if(!out){
		fprintf(stderr,"Error al crear output test");
		return OUTPUT_TEST_FILE_ERROR;
	}
	#endif
	error_code = init_pcm_file(audio,0l);
	if(error_code){
		return error_code;
	}
	/*Stdout print info for debugging*/
	print_samples_data(audio->samples);
	print_header_data(audio->header);

	/*Inicializacion del buffer de lectura temporal*/
	sample_buffer = (uint8_t*)malloc(sizeof(uint8_t)* audio->samples->size_of_each_sample);
#ifdef OUTFILE
	load_limits(&num_limits,audio->header->bits_per_sample);
#endif
	/*Lectura de muestras del fichero PCM*/
	for(i = 0; i < audio->samples->num_samples; i++){
		if(fread(sample_buffer,audio->samples->size_of_each_sample,1, audio->file_flux)){
			for(current_channel = 0;  current_channel < audio->header->channels; current_channel++){
				current_data = read_pcm_channel(audio->samples,sample_buffer,current_channel,i);
				#ifdef OUTFILE
				if(current_channel == 0)
					write_test_file(out,current_data,&num_limits);
				#endif
			}
		}
	}
	/*Liberamos recursos*/
	free(sample_buffer);
#ifdef OUTFILE
	fclose(out);
#endif
	return 0;
}
Example #3
0
int main() {
	write_test_file(test_file_name);
	
	run(test_read_element_id_with_full_buffer);
	run(test_read_element_id_error_cases);
	run(test_read_data_size_with_full_buffer);
	run(test_read_data_size_error_cases);
	run(test_read_data_size_unknown_sizes);
	run(test_read_element_and_element_header);
	run(test_read_int_and_uint);
	
	unlink(test_file_name);
	return show_report();
}
QString
QcFileTileCache::base_cache_directory()
{
  // Try the shared cache first and use a specific directory. (e.g. ~/.cache/QtLocation)
  // If this is not supported by the platform, use the application-specific cache location.
  // (e.g. ~/.cache/<app_name>/QtLocation)

  // /data/user/11/org.qtproject.example.mapviewer_atk/cache/QtCarto/
#ifdef ANDROID
  QString generic_data_location_path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
  // qInfo() << "GenericDataLocation:" << generic_data_location_path;
  QString application_user_directory_path = QDir(generic_data_location_path).filePath("alpine-toolkit");
  QString directory = application_user_directory_path + QDir::separator() + QLatin1Literal("cache");
#else
  QString directory = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
#endif
  // qInfo() << "base_cache_directory" << directory;

  // Check we can write on the cache directory
  if (!directory.isEmpty()) {
    // The shared cache may not be writable when application isolation is enforced.
    static bool cache_directory_writable = false; // static for later use
    static bool cache_directory_writable_checked = false;
    if (!cache_directory_writable_checked) {
      cache_directory_writable_checked = true;
      QDir::root().mkpath(directory);
      QFile write_test_file(QDir(directory).filePath(QLatin1Literal("qt_cache_check")));
      cache_directory_writable = write_test_file.open(QIODevice::WriteOnly);
      if (cache_directory_writable)
	write_test_file.remove();
    }
    if (!cache_directory_writable)
      directory = QString();
  }

  if (directory.isEmpty())
    directory = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);

  if (!directory.endsWith(QLatin1Char('/')))
    directory += QLatin1Char('/');
  directory += QLatin1Literal("QtCarto/");

  // qInfo() << "base_cache_directory" << directory;
  return directory;
}
Example #5
0
void process_ipp_file(const fs::path& file, bool positive_test)
{
   std::cout << "Info: Scanning file: " << file.string() << std::endl;

   // our variables:
   std::string file_text;
   std::string macro_name;
   std::string namespace_name;
   fs::path positive_file;
   fs::path negative_file;

   // load the file into memory so we can scan it:
   fs::ifstream ifs(file);
   std::copy(std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>(), std::back_inserter(file_text));
   ifs.close();
   // scan for the macro name:
   boost::regex macro_regex("//\\s*MACRO\\s*:\\s*(\\w+)");
   boost::smatch macro_match;
   if(boost::regex_search(file_text, macro_match, macro_regex))
   {
      macro_name = macro_match[1];
      macro_list.insert(macro_name);
      namespace_name = boost::regex_replace(file_text, macro_regex, "\\L$1", boost::format_first_only | boost::format_no_copy);
   }
   if(macro_name.empty())
   {
      std::cout << "Error: no macro definition found in " << file.string();
   }
   else
   {
      std::cout << "Info: Macroname: " << macro_name << std::endl;
   }

   // get the output filesnames:
   boost::regex file_regex("boost_([^.]+)\\.ipp");
   positive_file = file.branch_path() / boost::regex_replace(file.leaf().string(), file_regex, "$1_pass.cpp");
   negative_file = file.branch_path() / boost::regex_replace(file.leaf().string(), file_regex, "$1_fail.cpp");
   write_test_file(positive_file, macro_name, namespace_name, file.leaf().string(), positive_test, true);
   write_test_file(negative_file, macro_name, namespace_name, file.leaf().string(), positive_test, false);
   
   // always create config_test data,
   // positive and negative tests go to separate streams, because for some
   // reason some compilers choke unless we put them in a particular order...
   std::ostream* pout = positive_test ? &config_test1a : &config_test1;
   *pout << "#if";
   if(!positive_test)
      *pout << "n";
   *pout << "def " << macro_name 
      << "\n#include \"" << file.leaf().string() << "\"\n#else\nnamespace "
      << namespace_name << " = empty_boost;\n#endif\n";

   config_test2 << "   if(0 != " << namespace_name << "::test())\n"
      "   {\n"
      "      std::cerr << \"Failed test for " << macro_name << " at: \" << __FILE__ << \":\" << __LINE__ << std::endl;\n"
      "      ++error_count;\n"
      "   }\n";

   // always generate the jamfile data:
   jamfile << "test-suite \"" << macro_name << "\" : \n"
      "[ run " << positive_file.leaf().string() << " <template>config_options ]\n"
      "[ compile-fail " << negative_file.leaf().string() << " <template>config_options ] ;\n";

   jamfile_v2 << "test-suite \"" << macro_name << "\" : \n"
      "[ run ../" << positive_file.leaf().string() << " ]\n"
      "[ compile-fail ../" << negative_file.leaf().string() << " ] ;\n";

   // Generate data for the Build-checks test file:
   build_config_test << "#ifdef TEST_" << macro_name << std::endl;
   build_config_test << "#  include \"../test/" << file.leaf().string() << "\"\n";
   build_config_test << "namespace test = " << namespace_name << ";\n#endif\n";

   // Generate data for the build-checks Jamfile:
   static const boost::regex feature_regex("boost_(?:no|has)_(.*)");
   std::string feature_name = boost::regex_replace(namespace_name, feature_regex, "\\1");
   build_config_jamfile << "run-simple test_case.cpp : : : <define>TEST_" << macro_name << " : " << feature_name << " ;\n";
   build_config_jamfile << "alias " << feature_name << " : " << feature_name << ".output ;\n";
   build_config_jamfile << "explicit " << feature_name << " ;\n";
}
int mount_main(int argc, char *argv[])
{
    int  ret;

#ifndef CONFIG_EXAMPLES_MOUNT_DEVNAME
    /* Create a RAM disk for the test */

    ret = create_ramdisk();
    if (ret < 0)
    {
        printf("mount_main: ERROR failed to create RAM disk\n");
        return 1;
    }
#endif

    /* Mount the test file system (see arch/sim/src/up_deviceimage.c */

    printf("mount_main: mounting %s filesystem at target=%s with source=%s\n",
           g_filesystemtype, g_target, g_source);

    ret = mount(g_source, g_target, g_filesystemtype, 0, NULL);
    printf("mount_main: mount() returned %d\n", ret);

    if (ret == 0)
    {
        show_statfs(g_mntdir);
        show_statfs(g_target);

#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        /* Read a test file that is already on the test file system image */

        show_directories("", 0);
        succeed_stat(g_testfile1);
        show_statfs(g_testfile1);
        read_test_file(g_testfile1);
#else
        /* Create the test directory that would have been on the canned filesystem */

        succeed_mkdir(g_testdir1);
        show_directories("", 0);
        succeed_stat(g_testdir1);
        show_statfs(g_testdir1);
#endif

        /* Write a test file into a pre-existing directory on the test file system */

        fail_stat(g_testfile2, ENOENT);
        write_test_file(g_testfile2);
        show_directories("", 0);
        succeed_stat(g_testfile2);
        show_statfs(g_testfile2);

        /* Read the file that we just wrote */

        read_test_file(g_testfile2);

        /* Try rmdir() against a file on the directory.  It should fail with ENOTDIR */
#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        fail_rmdir(g_testfile1, ENOTDIR);
#endif

        /* Try rmdir() against the test directory.  It should fail with ENOTEMPTY */

        fail_rmdir(g_testdir1, ENOTEMPTY);

        /* Try unlink() against the test directory.  It should fail with EISDIR */

        fail_unlink(g_testdir1, EISDIR);

        /* Try unlink() against the test file1.  It should succeed. */
#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        succeed_unlink(g_testfile1);
        fail_stat(g_testfile1, ENOENT);
        show_directories("", 0);
#endif

        /* Attempt to open testfile1 should fail with ENOENT */
#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        fail_read_open(g_testfile1, ENOENT);
#endif
        /* Try rmdir() against the test directory.  It should still fail with ENOTEMPTY */

        fail_rmdir(g_testdir1, ENOTEMPTY);

        /* Try mkdir() against the test file2.  It should fail with EEXIST. */

        fail_mkdir(g_testfile2, EEXIST);

        /* Try unlink() against the test file2.  It should succeed. */

        succeed_unlink(g_testfile2);
        show_directories("", 0);
        fail_stat(g_testfile2, ENOENT);

        /* Try mkdir() against the test dir1.  It should fail with EEXIST. */

        fail_mkdir(g_testdir1, EEXIST);

        /* Try rmdir() against the test directory.  mkdir should now succeed. */

        succeed_rmdir(g_testdir1);
        show_directories("", 0);
        fail_stat(g_testdir1, ENOENT);

        /* Try mkdir() against the test dir2.  It should succeed */

        succeed_mkdir(g_testdir2);
        show_directories("", 0);
        succeed_stat(g_testdir2);
        show_statfs(g_testdir2);

        /* Try mkdir() against the test dir2.  It should fail with EXIST */

        fail_mkdir(g_testdir2, EEXIST);

        /* Write a test file into a new directory on the test file system */

        fail_stat(g_testfile3, ENOENT);
        write_test_file(g_testfile3);
        show_directories("", 0);
        succeed_stat(g_testfile3);
        show_statfs(g_testfile3);

        /* Read the file that we just wrote */

        read_test_file(g_testfile3);

        /* Use mkdir() to create test dir3.  It should succeed */

        fail_stat(g_testdir3, ENOENT);
        succeed_mkdir(g_testdir3);
        show_directories("", 0);
        succeed_stat(g_testdir3);
        show_statfs(g_testdir3);

        /* Try rename() on the root directory. Should fail with EXDEV*/

        fail_rename(g_target, g_testdir4, EXDEV);

        /* Try rename() to an existing directory.  Should fail with EEXIST */

        fail_rename(g_testdir2, g_testdir3, EEXIST);

        /* Try rename() to a non-existing directory.  Should succeed */

        fail_stat(g_testdir4, ENOENT);
        succeed_rename(g_testdir3, g_testdir4);
        show_directories("", 0);
        fail_stat(g_testdir3, ENOENT);
        succeed_stat(g_testdir4);
        show_statfs(g_testdir4);

        /* Try rename() of file.  Should work. */

        fail_stat(g_testfile4, ENOENT);
        succeed_rename(g_testfile3, g_testfile4);
        show_directories("", 0);
        fail_stat(g_testfile3, ENOENT);
        succeed_stat(g_testfile4);
        show_statfs(g_testfile4);

        /* Make sure that we can still read the renamed file */

        read_test_file(g_testfile4);

        /* Unmount the file system */

        printf("mount_main: Try unmount(%s)\n", g_target);

        ret = umount(g_target);
        if (ret != 0)
        {
            printf("mount_main: ERROR umount() failed, errno %d\n", errno);
            g_nerrors++;
        }

        printf("mount_main: %d errors reported\n", g_nerrors);
    }

    fflush(stdout);
    return 0;
}