File: zerolen.c

package info (click to toggle)
parted 3.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 17,324 kB
  • sloc: ansic: 73,015; sh: 11,628; makefile: 645; perl: 179; python: 44; asm: 36; sed: 16
file content (52 lines) | stat: -rw-r--r-- 1,357 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <config.h>
#include <unistd.h>

#include <check.h>

#include <parted/parted.h>

#include "common.h"
#include "progname.h"

static const char* temporary_disk;

/* TEST: Probe a zero-length disk image without raising an exception */
START_TEST (test_probe)
{
        PedDevice* dev = ped_device_get (temporary_disk);
        if (dev)
                ped_device_destroy (dev);
}
END_TEST

int
main (int argc, char **argv)
{
        set_program_name (argv[0]);
        int number_failed;
        Suite* suite = suite_create ("ZeroLen");
        TCase* tcase_probe = tcase_create ("Probe");

        if (argc < 2) {
                fail ("Insufficient arguments");
                return EXIT_FAILURE;
        }
        temporary_disk = argv[1];
        setenv ("PARTED_TEST_DEVICE_LENGTH", "0", 1);

        /* Fail when an exception is raised */
        ped_exception_set_handler (_test_exception_handler);

        tcase_add_test (tcase_probe, test_probe);
        /* Disable timeout for this test */
        tcase_set_timeout (tcase_probe, 0);
        suite_add_tcase (suite, tcase_probe);

        SRunner* srunner = srunner_create (suite);
        srunner_run_all (srunner, CK_VERBOSE);

        number_failed = srunner_ntests_failed (srunner);
        srunner_free (srunner);

        return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}