int main(int argc, char** args) {
    pthread_t thread1;
    pthread_t thread2;
    pthread_attr_t attr;
    char* job1 = "job1.axy";
    char* job2 = "job2.axy";

    fits_use_error_system();
    
    log_init(LOG_VERB);
    log_set_thread_specific();

	logverb("Hello world!\n");

    be = engine_new();
    engine_parse_config_file(be, "astrometry.cfg");

    pthread_mutex_init(&read_job_mutex, NULL);

    pthread_attr_init(&attr);
    pthread_create(&thread1, &attr, threadfunc, job1);
    pthread_create(&thread2, &attr, threadfunc, job2);

    pthread_join(thread1, NULL);
    pthread_join(thread2, NULL);

    pthread_mutex_destroy(&read_job_mutex);

    engine_free(be);

    return 0;
}
Example #2
0
void test_log_ts(CuTest* tc) {
    pthread_t t1, t2;
    FILE *f1, *f2;
    char *fn1, *fn2;
    sl* lst;

    log_init(LOG_VERB);
    logmsg("Logging initialized.\n");

    log_set_thread_specific();
    logmsg("Logging set thread specific.\n");

    fn1 = create_temp_file("log", "/tmp");
    fn2 = create_temp_file("log", "/tmp");

    logmsg("File 1 is %s\n", fn1);
    logmsg("File 2 is %s\n", fn2);

    f1 = fopen(fn1, "w");
    f2 = fopen(fn2, "w");

    CuAssertIntEquals(tc, 0, pthread_create(&t1, NULL, thread1, f1));
    CuAssertIntEquals(tc, 0, pthread_create(&t2, NULL, thread2, f2));

    CuAssertIntEquals(tc, 0, pthread_join(t1, NULL));
    CuAssertIntEquals(tc, 0, pthread_join(t2, NULL));

    fclose(f1);
    fclose(f2);

    lst = file_get_lines(fn1, FALSE);
    CuAssertIntEquals(tc, 0, strcmp(sl_get(lst, 0), STRING1A));
    CuAssertIntEquals(tc, 1, sl_size(lst));
    sl_free2(lst);

    lst = file_get_lines(fn2, FALSE);
    CuAssertIntEquals(tc, 0, strcmp(sl_get(lst, 0), STRING2A));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(lst, 1), STRING2B));
    CuAssertIntEquals(tc, 2, sl_size(lst));
    sl_free2(lst);

    unlink(fn1);
    unlink(fn2);
    free(fn1);
    free(fn2);
}