forked from acozzette/BUSE
-
Notifications
You must be signed in to change notification settings - Fork 4
/
tests.c
66 lines (56 loc) · 6.49 KB
/
tests.c
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <ctype.h>
#include "buse.h"
#include "vsfat.h"
#include "tests.h"
//Test function used to stuff in a hard coded dir and files
static void build_files()
{
unsigned char direntry[] = {0x42, 0x74, 0x00, 0x77, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6B, 0x00, 0x0F, 0x00, 0x6D, 0x2E, 0x00, 0x74, 0x00, 0x78, 0x00, 0x74, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x6D, 0x00, 0x61, 0x00, 0x63, 0x00, 0x20, 0x00, 0x66, 0x00, 0x0F, 0x00, 0x6D, 0x61, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x4D, 0x41, 0x43, 0x46, 0x41, 0x53, 0x7E, 0x31, 0x54, 0x58, 0x54, 0x20, 0x00, 0x00, 0xA0, 0xB8, 0x66, 0x4B, 0x66, 0x4B, 0x00, 0x00, 0xA0, 0xB8, 0x66, 0x4B, 0x03, 0x00, 0x9C, 0x00, 0x00, 0x00, 0x42, 0x68, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x2E, 0x00, 0x0F, 0x00, 0x44, 0x74, 0x00, 0x78, 0x00, 0x74, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x70, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x0F, 0x00, 0x44, 0x20, 0x00, 0x69, 0x00, 0x61, 0x00, 0x20, 0x00, 0x64, 0x00, 0x75, 0x00, 0x00, 0x00, 0x74, 0x00, 0x63, 0x00, 0x50, 0x45, 0x4C, 0x4C, 0x41, 0x49, 0x7E, 0x31, 0x54, 0x58, 0x54, 0x20, 0x00, 0x00, 0xA0, 0xB8, 0x66, 0x4B, 0x66, 0x4B, 0x00, 0x00, 0xA0, 0xB8, 0x66, 0x4B, 0x04, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x42, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x0F, 0x00, 0x78, 0x61, 0x00, 0x2E, 0x00, 0x74, 0x00, 0x78, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x72, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x73, 0x00, 0x20, 0x00, 0x0F, 0x00, 0x78, 0x70, 0x00, 0x61, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x00, 0x00, 0x73, 0x00, 0x20, 0x00, 0x52, 0x45, 0x4E, 0x53, 0x50, 0x41, 0x7E, 0x31, 0x54, 0x58, 0x54, 0x20, 0x00, 0x00, 0xA0, 0xB8, 0x66, 0x4B, 0x66, 0x4B, 0x00, 0x00, 0xA0, 0xB8, 0x66, 0x4B, 0x05, 0x00, 0xD7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char file1[] = {0x73, 0x79, 0x73, 0x63, 0x74, 0x6C, 0x20, 0x2D, 0x77, 0x20, 0x6B, 0x65, 0x72, 0x6E, 0x2E, 0x69, 0x70, 0x63, 0x2E, 0x6D, 0x61, 0x78, 0x73, 0x6F, 0x63, 0x6B, 0x62, 0x75, 0x66, 0x3D, 0x38, 0x33, 0x38, 0x38, 0x36, 0x30, 0x38, 0x0A, 0x73, 0x79, 0x73, 0x63, 0x74, 0x6C, 0x20, 0x2D, 0x77, 0x20, 0x6E, 0x65, 0x74, 0x2E, 0x69, 0x6E, 0x65, 0x74, 0x2E, 0x74, 0x63, 0x70, 0x2E, 0x73, 0x65, 0x6E, 0x64, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3D, 0x32, 0x30, 0x39, 0x37, 0x31, 0x35, 0x32, 0x0A, 0x73, 0x79, 0x73, 0x63, 0x74, 0x6C, 0x20, 0x2D, 0x77, 0x20, 0x6E, 0x65, 0x74, 0x2E, 0x69, 0x6E, 0x65, 0x74, 0x2E, 0x74, 0x63, 0x70, 0x2E, 0x72, 0x65, 0x63, 0x76, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3D, 0x32, 0x30, 0x39, 0x37, 0x31, 0x35, 0x32, 0x0A, 0x73, 0x79, 0x73, 0x63, 0x74, 0x6C, 0x20, 0x2D, 0x77, 0x20, 0x6E, 0x65, 0x74, 0x2E, 0x69, 0x6E, 0x65, 0x74, 0x2E, 0x74, 0x63, 0x70, 0x2E, 0x64, 0x65, 0x6C, 0x61, 0x79, 0x65, 0x64, 0x5F, 0x61, 0x63, 0x6B, 0x3D, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char file2[] = {0x6A, 0x65, 0x66, 0x66, 0x0A, 0x36, 0x34, 0x31, 0x2D, 0x37, 0x38, 0x30, 0x2D, 0x32, 0x39, 0x30, 0x36, 0x0A, 0x6A, 0x65, 0x66, 0x66, 0x75, 0x40, 0x66, 0x6C, 0x79, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x69, 0x63, 0x61, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char file3[] = {0x32, 0x31, 0x3A, 0x0A, 0x44, 0x69, 0x6D, 0x73, 0x75, 0x6D, 0x0A, 0x4E, 0x65, 0x6C, 0x73, 0x6F, 0x6E, 0x2D, 0x41, 0x74, 0x6B, 0x69, 0x6E, 0x73, 0x20, 0x4D, 0x75, 0x73, 0x65, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x41, 0x72, 0x74, 0x0A, 0x3F, 0x20, 0x41, 0x69, 0x72, 0x6C, 0x69, 0x6E, 0x65, 0x20, 0x48, 0x69, 0x73, 0x74, 0x6F, 0x72, 0x79, 0x20, 0x4D, 0x75, 0x73, 0x65, 0x75, 0x6D, 0x0A, 0x51, 0x33, 0x39, 0x0A, 0x43, 0x68, 0x65, 0x63, 0x6B, 0x69, 0x6E, 0x20, 0x48, 0x6F, 0x74, 0x65, 0x6C, 0x0A, 0x0A, 0x32, 0x32, 0x3A, 0x20, 0x0A, 0x42, 0x72, 0x65, 0x61, 0x6B, 0x66, 0x61, 0x73, 0x74, 0x20, 0x40, 0x20, 0x52, 0x69, 0x76, 0x65, 0x72, 0x20, 0x4D, 0x61, 0x72, 0x6B, 0x65, 0x74, 0x0A, 0x45, 0x77, 0x69, 0x6E, 0x67, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x4D, 0x75, 0x72, 0x69, 0x65, 0x6C, 0x20, 0x4B, 0x61, 0x75, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x4D, 0x65, 0x6D, 0x6F, 0x72, 0x69, 0x61, 0x6C, 0x20, 0x47, 0x61, 0x72, 0x64, 0x65, 0x6E, 0x0A, 0x57, 0x65, 0x73, 0x74, 0x70, 0x6F, 0x72, 0x74, 0x0A, 0x50, 0x68, 0x6F, 0x20, 0x6C, 0x75, 0x6E, 0x63, 0x68, 0x0A, 0x50, 0x6C, 0x61, 0x7A, 0x61, 0x0A, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x20, 0x68, 0x6F, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x77, 0x6F, 0x72, 0x6B, 0x20, 0x6F, 0x6E, 0x20, 0x52, 0x65, 0x6E, 0x27, 0x73, 0x20, 0x73, 0x74, 0x75, 0x66, 0x66, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
(void)direntry;
(void)file1;
(void)file2;
(void)file3;
//files = malloc (sizeof (filedata));
//memcpy (files, filedata, sizeof (filedata));
//add_address_region (part1_base + 823296, sizeof (filedata), files, 0);
}
//Test the read function
static void testRead(uint32_t size, uint32_t location)
{
// uint32_t size=atoi(argv[2]); // 100;
// uint32_t location = part1_base + atoi(argv[3]);// 3072;
unsigned char *buf = malloc(size);
xmp_read(buf, size, location, &xmpl_debug);
uint32_t pos = 0;
while (size > 0)
{
if (pos % 8 == 0)
{
fprintf(stderr, "\n%02x ", location);
}
fprintf(stderr, "%02x ", buf[pos++]);
size--;
location++;
}
fprintf(stderr, "\n");
}
//Test address mapping methods
static void testUtilities()
{
fprintf(stderr, "root dir loc: %u\n", root_dir_loc());
fprintf(stderr, "cluster for 1871872: %u\n", clus_from_addr(1871872));
fprintf(stderr, "fat entry for 1871872: %u\n", fat_entry_from_addr(1871872));
#if defined(ENV64BIT)
fprintf(stderr, "address for cluster 2: %lu\n", address_from_fatclus(2));
#else
fprintf(stderr, "address for cluster 2: %llu\n", address_from_fatclus(2));
#endif
}