Пример #1
0
// Test setting ranges of bits.
int test_bitmap_range() {
    pmem_bitmap *b = pmem_bitmap_make(0x100);

    // Simple case: all in one byte.
    pmem_bitmap_set(b, 2, 4);
    uint64_t expected_bits[] = {2, 3, 4, 5};
    if (verify_map(b, expected_bits, 4)) {
        return -1;
    }

    // Now set stuff across byte boundaries.
    pmem_bitmap_set(b, 14, 12);
    pmem_bitmap_set(b, 100, 1);
    uint64_t expected_bits2[] = {
        2, 3, 4, 5, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 100
    };
    if (verify_map(b, expected_bits2, 17)) {
        return -2;
    }

    // High and low byte with no middle.
    pmem_bitmap_set(b, 30, 5);
    uint64_t expected_bits3[] = {
        2, 3, 4, 5, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
        30, 31, 32, 33, 34,
        100
    };
    if (verify_map(b, expected_bits3, 22)) {
        return -2;
    }

    pmem_bitmap_destroy(b);
    return 0;
}
Пример #2
0
static int test(char *filename, int num_progs)
{
	int i, fd, map0_fds[num_progs], map1_fds[num_progs];

	for (i = 0; i < num_progs; i++) {
		if (load_bpf_file(filename)) {
			fprintf(stderr, "%s", bpf_log_buf);
			return 1;
		}
		printf("prog #%d: map ids %d %d\n", i, map_fd[0], map_fd[1]);
		map0_fds[i] = map_fd[0];
		map1_fds[i] = map_fd[1];
	}

	/* current load_bpf_file has perf_event_open default pid = -1
	 * and cpu = 0, which permits attached bpf execution on
	 * all cpus for all pid's. bpf program execution ignores
	 * cpu affinity.
	 */
	/* trigger some "open" operations */
	fd = open(filename, O_RDONLY);
	if (fd < 0) {
		fprintf(stderr, "open failed: %s\n", strerror(errno));
		return 1;
	}
	close(fd);

	/* verify the map */
	for (i = 0; i < num_progs; i++) {
		verify_map(map0_fds[i]);
		verify_map(map1_fds[i]);
	}

	return 0;
}
Пример #3
0
// Setting a crazy high bit should work - test resizing.
int test_bitmap_high_bit() {
    pmem_bitmap *b = pmem_bitmap_make(0x10);

    // Page-aligned values often catch off-by-one errors.
    pmem_bitmap_set(b, 0x400000, 1);
    uint64_t expected_bits[] = {0x400000};
    if (verify_map(b, expected_bits, 1) != 0) {
        return -1;
    }

    pmem_bitmap_destroy(b);
    return 0;
}
Пример #4
0
// Test filling the bitmap out of sequence.
int test_bitmap_nonsequential() {
    pmem_bitmap *b = pmem_bitmap_make(0);

    pmem_bitmap_set(b, 60, 1);
    pmem_bitmap_set(b, 19, 1);

    uint64_t expected_bits[] = {19, 60};
    if (verify_map(b, expected_bits, 2) != 0) {
        return -1;
    }

    pmem_bitmap_destroy(b);
    return 0;
}
Пример #5
0
// Test basic bitmap behavior.
int test_bitmap() {
    pmem_bitmap *b = pmem_bitmap_make(1); // Forcing growth.

    if (b->highest_bit != 0) {
        return -1;
    }

    pmem_bitmap_set(b, 19, 1);
    pmem_bitmap_set(b, 60, 1);

    uint64_t expected_bits[] = {19, 60};
    if (verify_map(b, expected_bits, 2) != 0) {
        return -2;
    }

    pmem_bitmap_destroy(b);
    return 0;
}
Пример #6
0
 void set_map(SafePointNode* m)      { _map = m; debug_only(verify_map()); }