-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.h
69 lines (56 loc) · 3.01 KB
/
tests.h
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
67
68
69
/* sfs_test.c
*
* Written by Xiru Zhu for Assignment 3.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include "sfs_api.h"
/* The maximum file name length. We assume that filenames can contain
* upper-case letters and periods ('.') characters. Feel free to
* change this if your implementation differs.
*/
#define MAX_FNAME_LENGTH 10 /* Assume at most 20 characters (16.3) */
/* The maximum number of files to attempt to open or create. NOTE: we
* do not _require_ that you support this many files. This is just to
* test the behavior of your code.
*/
#define MAX_FD 32
/* The maximum number of bytes we'll try to write to a file. If you
* support much shorter or larger files for some reason, feel free to
* reduce this value.
*/
#define MAX_BYTES 30000 // 16 * 30000
//The maximal number of bytes I will write for a single write
#define MAX_WRITE_BYTE 2025
//Don't change these values
#define ABS_CAP_FD 4092
#define ABS_CAP_FILE_SIZE 2000000
static char test_str[] = "Graphic Card is life. I need a 1080 for Christmas. As a side note, it's quite obvious when people copy from github. Usually there's more than one guy copying for the same repository.\n";
//Random Text Generators
char *rand_name();
//Seek
int test_seek(int *file_id, int *file_size, int *write_ptr, char **write_buf, int num_file, int offset, int *err_no);
//Read Functions
int test_read_all_files(int *file_id, int *file_size, char **write_buf, int num_file, int *err_no);
int test_simple_read_files(int *file_id, int *file_size, char **write_buf, int num_file, int *err_no);
int test_difficult_read_files(int *file_id, int *file_size, int *write_ptr, char **write_buf, int index, int read_length, int *err_no);
int test_random_read_files(int *file_id, int *file_size, int *write_ptr, char **write_buf ,int num_file, int *err_no);
//Write Function
int test_simple_write_files(int *file_id, int *file_size, int *write_ptr, char **write_buf, int num_file, int *err_no);
int test_difficult_write_files(int *file_id, int *file_size, int *write_ptr, char **write_buf, int num_file, int *err_no);
int test_write_to_overflow(int *file_id, int *file_size, char **write_buf, int num_file, int *err_no);
int test_read_write_out_of_bound(int *file_id, int *file_sizes, char **file_names, int num_file, int *err_no);
//Close/Remove Functions
int test_remove_files(int *file_id, int *file_size, int *write_ptr, char **file_names, char **write_buf, int num_file, int *err_no);
int test_close_files(char **file_names, int *file_id, int num_file, int *err_no);
//Open file functions
int test_open_new_files(char **file_names, int *file_id, int num_file, int *err_no);
int test_open_old_files(char **file_names, int *file_id, int num_file, int *err_no);
int test_overflow_open(int *file_id, int *file_sizes, int *write_ptr, char **file_names, char **write_buf, int num_file, int *err_no);
//Test persistence
int test_persistence(int *error, int write_length);
//Help functionn
int free_name_element(char **name_list, int num_file);