Changeset c6bb567a


Ignore:
Timestamp:
Nov 29, 2018, 2:28:09 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
64d534d
Parents:
505b49a
Message:

[tests] add run_on_default_source helper

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/utils_tests.h

    r505b49a rc6bb567a  
    1919#ifndef PATH_MAX
    2020#define PATH_MAX 1024
     21#endif
     22
     23#ifndef AUBIO_TESTS_SOURCE
     24#error "AUBIO_TESTS_SOURCE is not defined"
    2125#endif
    2226
     
    7276#if defined(__GNUC__) // mkstemp
    7377
     78int check_source(char *source_path)
     79{
     80  return access(source_path, R_OK);
     81}
     82
    7483int create_temp_sink(char *sink_path)
    7584{
     
    8796#elif defined(HAVE_WIN_HACKS) //&& !defined(__GNUC__)
    8897// windows workaround, where mkstemp does not exist...
     98
     99int check_source(char *source_path)
     100{
     101  return _access(source_path, 04);
     102}
     103
    89104int create_temp_sink(char *templ)
    90105{
     
    113128#endif
    114129
     130// pass progname / default
     131int run_on_default_source( int main(int, char**) )
     132{
     133  const int argc = 2;
     134  int err = 0;
     135  char** argv = (char**)calloc(argc, sizeof(char*));
     136  argv[0] = __FILE__;
     137  argv[1] = AUBIO_TESTS_SOURCE;
     138  // check if the file can be read
     139  if ( check_source(argv[1]) ) return 1;
     140  err = main(argc, argv);
     141  if (argv) free(argv);
     142  return err;
     143}
    115144
    116145int run_on_default_sink( int main(int, char**) )
Note: See TracChangeset for help on using the changeset viewer.