38 lines
1.2 KiB
C
38 lines
1.2 KiB
C
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "resource_handler/resource_handler.h"
|
|
|
|
void check_extract_numbers(char *input, int correct_len, int *correct_buf) {
|
|
int test_buf[MAX_CORES];
|
|
int test_len = extract_numbers(input, test_buf);
|
|
//int correct_buf[] = {1,2,3,4,5,7,8};
|
|
//int correct_len = 7;
|
|
if(test_len==correct_len && memcmp(test_buf, correct_buf, test_len)==0) {
|
|
printf("test on string \"%s\" passed\n", input);
|
|
} else {
|
|
printf("test on string \"%s\" failed:\ncorrect len: %d,got len: %d\ngot result:", input, correct_len, test_len);
|
|
for(int i=0;i<test_len;i++) {
|
|
printf("%d ", *(test_buf+i));
|
|
}
|
|
printf("\n");
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int res1[]={1,2,3,4,5,7,8};
|
|
check_extract_numbers("1-5,7-8", 7, res1);
|
|
int res2[]={1};
|
|
check_extract_numbers("1", 1, res2);
|
|
int res3[]={};
|
|
check_extract_numbers("", 0, res3);
|
|
int* cores;
|
|
int num_cores;
|
|
num_cores=get_isolated_cores(&cores);
|
|
printf("your system has %d isolated cores: ", num_cores);
|
|
for(int i = 0; i < num_cores; i++) {
|
|
printf("%d,", *(cores+i));
|
|
}
|
|
printf("\n");
|
|
free(cores);
|
|
return 0;
|
|
}
|