Motr  M0
m0t1fs_io_file_pattern.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <assert.h>
24 
25 /*
26  * If the following sizes are to be changed, please ensure to update the
27  * numbers in m0t1fs_io_config_params.sh as well.
28  */
29 unsigned long long NUM_ALPHABETS = 26;
30 unsigned long long NUM_ALPHABET_REPEATITIONS = 4096;
31 unsigned long long NUM_ITERATIONS = 200;
32 
33 int main(int argc, char *argv[])
34 {
35  FILE *fd = NULL;
36  char ch;
37  int i, j, k;
38  unsigned long long total_size;
39  unsigned long long bytes = 0;
40  float total_size_MB;
41 
42  if (argc != 2) {
43  printf("Usage: %s output-file-name\n", argv[0]);
44  exit(1);
45  }
46  fd = fopen(argv[1], "w");
47  if (NULL == fd) {
48  printf("fopen() Error !!!\n");
49  return 1;
50  }
51  printf("File \"%s\" opened for writing\n", argv[1]);
52 
53  for (i = 0; i < NUM_ITERATIONS; ++i) {
54  ch = 'a';
55  for (j = 0; j < NUM_ALPHABETS; ++j, ++ch) {
56  for (k = 0; k < NUM_ALPHABET_REPEATITIONS; ++k) {
57  bytes = fwrite(&ch, sizeof(char), 1, fd);
58  /*
59  * bytes is collected here just to keep the
60  * compiler happy, during the RPM build. It is
61  * intentionally ignored here and then checked
62  * only once below, again to keep the compiler
63  * happy!
64  */
65  }
66  }
67  }
68  assert(bytes == sizeof(char));
71  assert(ftell(fd) == total_size);
72  fclose(fd);
73  total_size_MB = (float)total_size / 1024 / 1024;
74  printf("File \"%s\" closed after writing %llu bytes (%f MB)\n",
75  argv[1], total_size, total_size_MB);
76  exit(0);
77 }
#define NULL
Definition: misc.h:38
int main(int argc, char *argv[])
int i
Definition: dir.c:1033
unsigned long long NUM_ITERATIONS
unsigned long long NUM_ALPHABETS
struct m0t1fs_filedata * fd
Definition: dir.c:1030
unsigned long long NUM_ALPHABET_REPEATITIONS