Commit ff874c87 authored by Nagy Tibor's avatar Nagy Tibor
Browse files

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];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment