tests: More refactoring, add helper header to every test, override exit for better error reporting

This commit is contained in:
Tibor Nagy
2019-02-21 21:13:28 +01:00
parent 6266d29242
commit 9a0ea6ff34
99 changed files with 323 additions and 88 deletions
+2
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char * s = "azAZ9."; // test boundaries
long l = a64l(s);
+2
View File
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "test_helpers.h"
int main(void) {
char * ptr = (char *)malloc(256);
printf("malloc %p\n", ptr);
+2
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
double d = atof("-3.14");
printf("%f\n", d);
+2
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
printf("%d\n", atoi(" -42"));
printf("%d\n", atoi(" +555"));
+2
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int int_cmp(const void* a, const void* b) {
return *(const int*) a - *(const int*) b;
}
+18 -15
View File
@@ -1,20 +1,23 @@
#include <stdlib.h>
volatile float f;
volatile long double ld;
volatile unsigned long long ll;
lldiv_t mydivt;
#include "test_helpers.h"
volatile float f;
volatile long double ld;
volatile unsigned long long ll;
lldiv_t mydivt;
int main(void) {
char* tmp;
f = strtof("gnu", &tmp);
ld = strtold("gnu", &tmp);
ll = strtoll("gnu", &tmp, 10);
ll = strtoull("gnu", &tmp, 10);
ll = llabs(10);
mydivt = lldiv(10,1);
ll = mydivt.quot;
ll = mydivt.rem;
ll = atoll("10");
_Exit(0);
char* tmp;
f = strtof("gnu", &tmp);
ld = strtold("gnu", &tmp);
ll = strtoll("gnu", &tmp, 10);
ll = strtoull("gnu", &tmp, 10);
ll = llabs(10);
mydivt = lldiv(10,1);
ll = mydivt.quot;
ll = mydivt.rem;
ll = atoll("10");
_Exit(0);
}
+2
View File
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include "test_helpers.h"
int main(void) {
//puts(getenv("SHELL"));
//puts(getenv("CC"));
+2
View File
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <string.h>
#include "test_helpers.h"
int main(void) {
char* file_name = (char*) calloc(18, sizeof(char));
strcpy(file_name, "tempXXXXXX.suffix");
+2
View File
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <string.h>
#include "test_helpers.h"
int main(void) {
char* string = (char*) calloc(20, sizeof(char));
strcpy(string, "tempXXXXXX");
+2
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
printf("%d\n", rand());
srand(259);
+2
View File
@@ -4,6 +4,8 @@
#include <stdlib.h>
#include <string.h>
#include "test_helpers.h"
int main(void) {
char* path = realpath("stdlib/realpath.c", NULL);
if (!path) {
+2
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char* endptr = 0;
double d;
+2
View File
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
printf("%ld\n", strtol(" -42", NULL, 0));
printf("%ld\n", strtol(" +555", NULL, 0));
+2
View File
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
printf("%ld\n", strtoul(" -42", NULL, 0));
printf("%ld\n", strtoul(" +555", NULL, 0));
+4 -1
View File
@@ -1,5 +1,8 @@
#include <stdlib.h>
#include "test_helpers.h"
int main(void) {
system("echo test of system");
int status = system("echo test of system");
ERROR_IF(system, status, == -1);
}