alloctest.c
1.11 KB
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
#include "testlib.c"
char pname[256];
char *myname;
char *dname = DEVICE_NAME;
#include "fillcard.c"
int
main(int argc, char **argv)
{
BBCHandle h;
int loops = 0;
int cardsize, freeblks, reservedblks, badblks;
int rv;
int i = 0;
myname = argv[0];
if (argc > 1)
dname = argv[argc - 1];
while (1) {
sprintf(pname, "%s(%d)", myname, ++loops);
h = BBCInit(dname, BBC_SYNC);
printf("%s: BBCInit(%s) returns %d\n", pname, dname, h);
if (h < 0) continue;
while (!BBCCardPresent(h)) {
if ((++i & 0x1ff) == 0)
printf("%s: no card present ... wait\n", pname);
}
printf("%s: card is present\n", pname);
if (BBCStats(h, &cardsize, &reservedblks, &freeblks, &badblks) < 0) {
BBCClose(h);
continue;
}
printf("%s: BBCStats cardsize %d, freeblks %d\n", pname, cardsize, freeblks);
printf("%s: format card ...\n", pname);
rv = BBCSetLed(h, BBC_LED_ORANGE);
rv = BBCFormatCard(h);
printf("%s: BBCFormatCard returns %d\n", pname, rv);
if (h < 0) continue;
do_fill_card(h);
rv = BBCSetLed(h, BBC_LED_GREEN);
rv = BBCClose(h);
printf("%s: BBCClose returns %d\n", pname, rv);
}
exit(0);
}