~ubuntu-branches/ubuntu/natty/vlock/natty

« back to all changes in this revision

Viewing changes to tests/vlock-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt
  • Date: 2008-06-17 17:13:25 UTC
  • mfrom: (1.1.2 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080617171325-ic8yy6tol0165i96
Tags: 2.2.2-3
* Don't try to chgrp to "vlock" during build time (Closes: #486665)
* Bump standards version (No changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <stdio.h>
 
3
 
 
4
#include <CUnit/CUnit.h>
 
5
#include <CUnit/Basic.h>
 
6
 
 
7
#include "test_list.h"
 
8
#include "test_tsort.h"
 
9
#include "test_util.h"
 
10
#include "test_process.h"
 
11
 
 
12
CU_SuiteInfo vlock_test_suites[] = {
 
13
  { "test_list" , NULL, NULL, list_tests },
 
14
  { "test_tsort", NULL, NULL, tsort_tests },
 
15
  { "test_util", NULL, NULL, util_tests },
 
16
  { "test_process", NULL, NULL, process_tests },
 
17
  CU_SUITE_INFO_NULL,
 
18
};
 
19
 
 
20
int main(int __attribute__((unused)) argc, const char *argv[])
 
21
{
 
22
  char *output_mode = getenv("VLOCK_TEST_OUTPUT_MODE");
 
23
 
 
24
  if (CU_initialize_registry() != CUE_SUCCESS) {
 
25
    fprintf(stderr, "%s: CUnit initialization failed\n", argv[0]);
 
26
    exit(EXIT_FAILURE);
 
27
  }
 
28
 
 
29
  if (CU_register_suites(vlock_test_suites) != CUE_SUCCESS) {
 
30
    fprintf(stderr, "%s: registering test suites failed: %s\n", argv[0], CU_get_error_msg());
 
31
    goto error;
 
32
  }
 
33
 
 
34
  if (output_mode != NULL) {
 
35
    if (strcmp(output_mode, "verbose") == 0)
 
36
      CU_basic_set_mode(CU_BRM_VERBOSE);
 
37
    else if (strcmp(output_mode, "normal") == 0)
 
38
      CU_basic_set_mode(CU_BRM_NORMAL);
 
39
    else if (strcmp(output_mode, "silent") == 0)
 
40
      CU_basic_set_mode(CU_BRM_SILENT);
 
41
  }
 
42
 
 
43
  if (CU_basic_run_tests() != CUE_SUCCESS) {
 
44
    fprintf(stderr, "%s: running tests failed\n", argv[0]);
 
45
    goto error;
 
46
  }
 
47
 
 
48
  if (CU_get_number_of_tests_failed() > 0)
 
49
    goto error;
 
50
 
 
51
  CU_cleanup_registry();
 
52
  exit(EXIT_SUCCESS);
 
53
 
 
54
error:
 
55
  CU_cleanup_registry();
 
56
  exit(EXIT_FAILURE);
 
57
}