Commit ff874c87 authored by Nagy Tibor's avatar Nagy Tibor

tests: Fix function signatures

parent 97592716
......@@ -88,14 +88,14 @@ just in case, it'd be a good idea to map inputs to variables.
#include "string.h"
#include "stdio.h"
int main() {
// Don't do this
printf("%d\n", strcspn("Hello", "Hi"));
// Do this
char *first = "Hello";
char *second = "Hi";
printf("%d\n", strcspn(first, second));
int main(void) {
// Don't do this
printf("%d\n", strcspn("Hello", "Hi"));
// Do this
char *first = "Hello";
char *second = "Hi";
printf("%d\n", strcspn(first, second));
}
```
......@@ -120,4 +120,4 @@ You can test against verified correct output with `make verify` in the tests
directory. You will need to manually create the correct output and put it in the
tests/expected directory. Running any `make` commands in the tests directory
will ***not*** rebuild relibc, so you'll need to go back to the root directory
if you need to rebuild relibc.
\ No newline at end of file
if you need to rebuild relibc.
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
int main(int argc, char ** argv) {
int main(void) {
char *str = (char *) alloca(17);
memset(str, 'A', 16);
......
#include <string.h>
#include <unistd.h>
int main(int argc, char ** argv) {
int main(int argc, char *argv[]) {
int i;
for(i = 0; i < argc; i++) {
write(STDOUT_FILENO, argv[i], strlen(argv[i]));
......
......@@ -3,7 +3,7 @@
#include <string.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int main(void) {
uint32_t hl = 0xBADFACED;
uint32_t nl = htonl(hl);
assert(nl == 0xEDACDFBA);
......
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
int main() {
int main(void) {
assert(1 == 1);
assert(1 + 1 == 2);
puts("yay!");
......
......@@ -16,6 +16,6 @@ TEST(102)
TEST(103)
TEST(104)
int main(int argc, char *argv[]) {
int main(void) {
puts("main");
}
......@@ -293,7 +293,7 @@ size_t num_test_cases = sizeof(test_cases) / sizeof(struct test_case);
printf("Unexpected result: " #fn "('%c') != %d // Char value: %d\n", tc.c, tc.fn, tc.c); \
}
int main(int argc, char* argv[]) {
int main(void) {
int retval = 0;
for(int i = 0; i < num_test_cases; ++i) {
......
......@@ -16,6 +16,6 @@ TEST(102)
TEST(103)
TEST(104)
int main(int argc, char *argv[]) {
int main(void) {
puts("main");
}
......@@ -2,7 +2,7 @@
#include <errno.h>
#include <stdio.h>
int main() {
int main(void) {
printf("%lu\n", sizeof(struct dirent));
DIR* dir = opendir("example_dir/");
......
......@@ -7,7 +7,7 @@ int filter(const struct dirent* dirent) {
return strstr(dirent->d_name, "3") == NULL;
}
int main() {
int main(void) {
struct dirent** array;
int len = scandir("example_dir/", &array, filter, alphasort);
if (len < 0) {
......
......@@ -3,7 +3,7 @@
#include <string.h>
#include <errno.h>
int main(int argc, char** argv) {
int main(void) {
chdir("nonexistent");
printf("errno: %d = %s\n", errno, strerror(errno));
perror("perror");
......
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char ** argv) {
int main(void) {
int fd = creat("create.out", 0755);
if (fd >= 0) {
write(fd, "Hello World!\n", 13);
......
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <unistd.h>
int main() {
int main(void) {
//Lose our fd and pull it again
creat("fcntl.out", 0777);
int newfd = open("fcntl.out", 0);
......
......@@ -9,7 +9,7 @@ void test(char* pattern, char* input, int flags) {
}
}
int main() {
int main(void) {
puts("Should succeed:");
test("*World", "Hello World", 0);
test("*World", "World", 0);
......
......@@ -18,7 +18,7 @@ char * get_mutable_string(char *str) {
return copy;
}
void test_basename() {
void test_basename(void) {
test_case test_cases[] =
{ {"/usr/lib", "lib"},
{"//usr//lib//", "lib"},
......@@ -44,7 +44,7 @@ void test_basename() {
return;
}
void test_dirname() {
void test_dirname(void) {
test_case test_cases[] =
{ {"/usr/lib", "/usr"},
{"//usr//lib//", "//usr"},
......@@ -73,7 +73,7 @@ void test_dirname() {
return;
}
int main() {
int main(void) {
printf("Testing libgen.h\n");
test_basename();
test_dirname();
......
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
int main() {
int main(void) {
// TODO: Implement locale properly and test it here
char* val = setlocale(LC_ALL, NULL);
if (strcmp(val, "C") == 0) {
......
#include <math.h>
#include <stdio.h>
int main(int argc, char ** argv) {
int main(void) {
double pi = 3.14;
float c = cos(pi);
printf("cos(%f) = %f\n", pi, c);
......
......@@ -225,6 +225,6 @@ do_test (void)
return (error_count != 0);
}
int main() {
int main(void) {
do_test();
}
......@@ -13,7 +13,7 @@ void print(struct passwd *pwd) {
printf("pw_shell: %s\n", pwd->pw_shell);
}
int main() {
int main(void) {
puts("--- Checking getpwuid ---");
errno = 0;
struct passwd *pwd = getpwuid(0);
......
#include <regex.h>
#include <stdio.h>
int main() {
int main(void) {
regex_t regex;
char error_buf[256];
......
......@@ -6,7 +6,7 @@ void ptimeval(struct timeval* val) {
printf("{ tv_sec: %ld, tv_usec: %ld }\n", val->tv_sec, val->tv_usec);
}
int main() {
int main(void) {
struct rusage r_usage;
if (getrusage(RUSAGE_SELF, &r_usage) < 0) {
perror("getrusage");
......
......@@ -3,7 +3,7 @@
#include <sys/select.h>
#include <unistd.h>
int main() {
int main(void) {
int fd = open("select.c", 0, 0);
fd_set read;
......
#include <stdio.h>
#include <setjmp.h>
int main() {
int main(void) {
jmp_buf buf;
if (setjmp(buf)) {
puts("hi from jump");
......
......@@ -7,7 +7,7 @@ void handler(int sig) {
puts("Signal handler called!");
}
int main() {
int main(void) {
if (signal(SIGUSR1, &handler) == SIG_ERR) {
puts("Signal error!");
printf("%d\n", errno);
......
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv) {
int main(void) {
FILE *f = fopen("stdio/stdio.in", "r");
printf("%c\n", fgetc(f));
ungetc('H', f);
......
#include <stdio.h>
int main() {
int main(void) {
// Tests what used to be a bug with buffering
fwrite("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1, 999, stdout);
fwrite("Test\n", 1, 5, stdout);
......
#include <stdio.h>
int main() {
int main(void) {
//FILE *f = fopen("/etc/ssl/certs/ca-certificates.crt", "r");
FILE *f = fopen("stdio/stdio.in", "r");
char line[256];
......
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <errno.h>
int main(int argc, char ** argv) {
int main(void) {
FILE *f = fopen("stdio/fputs.out", "w");
char *in = "Hello World!";
fputs(in, f); // calls fwrite, helpers::fwritex, internal::to_write and internal::stdio_write
......
#include <errno.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
int main(void) {
FILE *fp = fopen("stdio/fread.in", "rb");
char buf[33] = { 0 };
......
#include <stdio.h>
int main(int argc, char ** argv) {
int main(void) {
freopen("stdio/stdio.in", "r", stdin);
char in[6];
fgets(in, 6, stdin);
......
#include <stdio.h>
int main() {
int main(void) {
FILE *f = fopen("stdio/stdio.in", "r");
if (fseek(f, 14, SEEK_CUR) < 0) {
puts("fseek error");
......
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <errno.h>
int main(int argc, char ** argv) {
int main(void) {
FILE *f = fopen("stdio/fwrite.out", "w");
const char ptr[] = "Hello World!";
......
#include <stdio.h>
int main(int argc, char ** argv) {
int main(void) {
ungetc('h', stdin);
char c;
if ((c = getchar()) == 'h') {
......
#include <stdio.h>
int main() {
int main(void) {
FILE* f = fopen("stdio/stdio.in", "r");
flockfile(f);
......
#include <stdio.h>
int main(int argc, char **argv) {
int main(void) {
FILE *fp;
int status;
char path[256];
......
#include <stdio.h>
int main(int argc, char ** argv) {
int main(void) {
int sofar = 0;
int len = printf(
"percent: %%\nstring: %s\nchar: %c\nchar: %c\nint: %d\n%nuint: %u\nhex: %x\nHEX: %X\nstring: %s\n",
......
......@@ -8,7 +8,7 @@ static char newpath[] = "new-name.out";
static char str[] = "Hello, World!";
int str_len = 13;
int main() {
int main(void) {
char buf[14];
buf[13] = 0x00;
int fd = creat(oldpath, 0777);
......
......@@ -25,7 +25,7 @@ void test(char* fmt_in, char* input, struct params *p, ...) {
);
}
int main(int argc, char ** argv) {
int main(void) {
struct params p = { .c = 'a' };
test("%hhd %d", "12 345", &p, &p.sa, &p.ia);
......
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv) {
int main(void) {
setvbuf(stdout, 0, _IONBF, 0);
FILE *f = fopen("stdio/stdio.in", "r");
setvbuf(f, 0, _IONBF, 0);
......
#include <stdio.h>
#include <string.h>
int main(int argc, char ** argv) {
int main(void) {
char buffer[72];
int ret = sprintf(
......
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char * s = "azAZ9."; // test boundaries
long l = a64l(s);
if (l != 194301926) {
......
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv) {
int main(void) {
char * ptr = (char *)malloc(256);
printf("malloc %p\n", ptr);
int i;
......
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
double d = atof("-3.14");
printf("%f\n", d);
return 0;
......
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
printf("%d\n", atoi(" -42"));
printf("%d\n", atoi(" +555"));
printf("%d\n", atoi(" 1234567890 "));
......
......@@ -19,7 +19,7 @@ int int_cmp(const void* a, const void* b) {
int main(int argc, char* argv[]) {
int main(void) {
int x = 0;
int y = 1024;
......
......@@ -3,10 +3,9 @@
volatile long double ld;
volatile unsigned long long ll;
lldiv_t mydivt;
int
main ()
{
char* tmp;
int main(void) {
char* tmp;
f = strtof("gnu", &tmp);
ld = strtold("gnu", &tmp);
ll = strtoll("gnu", &tmp, 10);
......
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
//puts(getenv("SHELL"));
//puts(getenv("CC"));
......
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv) {
int main(void) {
char* file_name = (char*) calloc(18, sizeof(char));
strcpy(file_name, "tempXXXXXX.suffix");
int fd = mkostemps(file_name, 7, 0);
......
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv) {
int main(void) {
char* string = (char*) calloc(20, sizeof(char));
strcpy(string, "tempXXXXXX");
mktemp(string);
......
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv) {
int main(void) {
printf("%d\n", rand());
srand(259);
printf("%d\n", rand());
......
......@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
char* path = realpath("stdlib/realpath.c", NULL);
if (!path) {
perror("realpath");
......
#include <stdlib.h>
#include <stdio.h>
int main() {
int main(void) {
char* endptr = 0;
double d;
......
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
printf("%ld\n", strtol(" -42", NULL, 0));
printf("%ld\n", strtol(" +555", NULL, 0));
printf("%ld\n", strtol(" 1234567890 ", NULL, 0));
......
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
printf("%ld\n", strtoul(" -42", NULL, 0));
printf("%ld\n", strtoul(" +555", NULL, 0));
printf("%ld\n", strtoul(" 1234567890 ", NULL, 0));
......
#include <stdlib.h>
int main(int argc, char ** argv) {
int main(void) {
system("echo test of system");
return 0;
}
......@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
int main(int argc, char ** argv) {
int main(void) {
puts("# mem #");
char arr[100];
memset(arr, 0, 100); // Compiler builtin, should work
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char dest1[12] = "hello";
printf("%s\n", strcat(dest1, " world")); // should be hello world
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
printf("%s\n", strchr("hello", 'e')); // should be ello
printf("%s\n", strchr("world", 'l')); // should be ld
printf("%i\n", strchr("world", 0) == NULL); // should be 1
......
#include <stdio.h>
#include <string.h>
int main() {
int main(void) {
char dst[20];
strcpy(dst, "strcpy works!");
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char *world = "world";
printf("%ld\n", strcspn("hello", world)); // should be 2
printf("%ld\n", strcspn("banana", world)); // should be 6
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
printf("%d\n", strncmp("a", "aa", 2));
printf("%d\n", strncmp("a", "aä", 2));
printf("%d\n", strncmp("\xFF", "\xFE", 2));
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char* source = "The quick drawn fix jumps over the lazy bug";
// should be "The quick drawn fix jumps over the lazy bug"
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char s0[] = "hello, world";
char* ptr = strrchr(s0, 'l');
if (ptr != &s0[10]) {
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char *hello = "hello";
char *world = "world";
char *banana = "banana";
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
printf("%s\n", strstr("In relibc we trust", "rust"));
printf("%s\n", strstr("In relibc we trust", "libc"));
printf("%s\n", strstr("In relibc we trust", "bugs"));
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, "
"is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.\n";
......
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int main(void) {
char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, "
"is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.\n";
char* sp;
......
......@@ -3,7 +3,7 @@
#include <stdio.h>
#include <strings.h>
int main() {
int main(void) {
assert(!bcmp("hello", "hehe", 2));
assert(bcmp("hello", "haha", 2));
......
#include <stdio.h>
#include <sys/utsname.h>
int main() {
int main(void) {
struct utsname system_info;
int result = uname(&system_info);
......
......@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
int main(void) {