Exemplo n.º 1
0
void
tests_rw(void)
{
    unsigned char *base = init_test_rw();
    int i;

    /* Read the initial handlers. */
    for (i = 1; i <= SIGMAX; i++)
        test_rw(i, NULL, base, SIGSETSIZE);

    /* Try each value of sigsetsize. */
    for (i = -1; i < SIGSETSIZE * 2 + 2; i++) {
        test_rw(SIG1, NULL, NULL, i);
        test_rw(SIG1, base, NULL, i);
        test_rw(SIG1, NULL, base, i);
        test_rw(SIG1, base, base, i);
    }

    /* Try each value of signum. */
    for (i = 0; i < SIGMAX + 2; i++) {
        test_rw(i, NULL, NULL, SIGSETSIZE);
        test_rw(i, base, NULL, SIGSETSIZE);
        test_rw(i, NULL, base, SIGSETSIZE);
        test_rw(i, base, base, SIGSETSIZE);
    }

    /* Try some random values. */
    for (i = 0; i < 1000; i++) {
        test_rw(rand() % (SIGMAX + 2),
                rand() % 2 == 0 ? NULL : base + rand() % SIGACTSZ,
                rand() % 2 == 0 ? NULL : base + rand() % SIGACTSZ,
                SIGSETSIZE + (rand() % 10 == 0 ? 1 : 0));
    }
}
Exemplo n.º 2
0
void test_device()
{
    //1. lll......
    FAT_PRINT("test read...\n");
    test_r();

    FAT_PRINT("test write...\n");
    test_w();

    FAT_PRINT("test read&write...\n");
    test_rw();
}
Exemplo n.º 3
0
BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, size_t block_size,
	int nb_passes, badblocks_report *report, FILE* fd)
{
	errcode_t error_code;
	blk_t first_block = 0, last_block = disk_size/block_size;

	if (report == NULL) return FALSE;
	num_read_errors = 0;
	num_write_errors = 0;
	num_corruption_errors = 0;
	report->bb_count = 0;
	if (fd != NULL) {
		log_fd = fd;
	} else {
		log_fd = freopen(NULL, "w", stderr);
	}

	error_code = bb_badblocks_list_create(&bb_list, 0);
	if (error_code) {
		uprintf("%sError %d while creating in-memory bad blocks list", bb_prefix, error_code);
		return FALSE;
	}

	cancel_ops = 0;
	/* use a timer to update status every second */
	SetTimer(hMainDialog, TID_BADBLOCKS_UPDATE, 1000, alarm_intr);
	report->bb_count = test_rw(hPhysicalDrive, last_block, block_size, first_block, BB_BLOCKS_AT_ONCE, nb_passes);
	KillTimer(hMainDialog, TID_BADBLOCKS_UPDATE);
	free(bb_list->list);
	free(bb_list);
	report->num_read_errors = num_read_errors;
	report->num_write_errors = num_write_errors;
	report->num_corruption_errors = num_corruption_errors;

	if ((cancel_ops) && (!report->bb_count))
		return FALSE;
	return TRUE;
}