aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile36
-rw-r--r--ft_read_test.c2
-rw-r--r--ft_write_test.c2
-rw-r--r--libasm_test.h12
-rw-r--r--main.c8
-rw-r--r--prettier.py11
6 files changed, 47 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 648cdbd..ddc3162 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,32 @@
RM = rm -f
-PYTHON = python3
+UNAME = $(shell uname)
+
+ifeq ($(UNAME), Linux)
+ PYTHON = python3.7
+else
+ PYTHON = python3
+endif
LIBASM_PATH = ../libasm
-CC = gcc
+CC = gcc -fPIC -no-pie
CCFLAGS = -I. -Wall -Wextra
LDFLAGS = -L$(LIBASM_PATH) -lasm
NAME = runtest
-SRC = main.c ft_strlen_test.c ft_strcpy_test.c ft_strcmp_test.c \
- ft_write_test.c ft_read_test.c ft_strdup_test.c helper.c \
- ft_atoi_base_test.c ft_list_push_front_test.c ft_list_size_test.c \
- ft_list_sort_test.c ft_list_remove_if_test.c \
+SRC = main.c \
+ helper.c \
+ ft_strlen_test.c \
+ ft_strcpy_test.c \
+ ft_strcmp_test.c \
+ ft_write_test.c \
+ ft_read_test.c \
+ ft_strdup_test.c \
+ ft_atoi_base_test.c \
functions_reference/ref_ft_atoi_base.c
+ #ft_list_push_front_test.c ft_list_size_test.c \
+ # ft_list_sort_test.c ft_list_remove_if_test.c \
+
OBJ = $(SRC:.c=.o)
run: pretty
@@ -21,23 +35,23 @@ pretty: all
./$(NAME) | $(PYTHON) prettier.py
run_raw: all
- ./$(NAME)
+ ./$(NAME)
all: $(NAME)
$(NAME): libasm_all $(OBJ)
- $(CC) $(LDFLAGS) -o $@ $(OBJ)
+ $(CC) -o $@ $(OBJ) $(LDFLAGS)
%.o: %.c
$(CC) $(CCFLAGS) -c -o $@ $<
-clean:
+clean:
$(RM) $(OBJ)
-fclean: clean
+fclean: clean
$(RM) $(NAME)
-re: libasm_fclean libasm_all fclean all
+re: libasm_fclean libasm_all fclean all
libasm_all:
diff --git a/ft_read_test.c b/ft_read_test.c
index 08c3c70..50a85bd 100644
--- a/ft_read_test.c
+++ b/ft_read_test.c
@@ -14,7 +14,7 @@ static int ret;
ret = ft_read(ft_read_pipe[0], buf, FT_READ_BUF_SIZE); \
buf[ret] = '\0'; \
if (strcmp(buf, str) != 0) \
- printf("KO: [COMPARE]: %s: expected: \"%s\" got: \"%s\"\n", test_name, str, buf); \
+ printf("KO: [COMPARE]: %s: expected: \"%s\" got: \"%s\"\n", test_name, str, buf); \
else \
print_ok(); \
close(ft_read_pipe[1]); \
diff --git a/ft_write_test.c b/ft_write_test.c
index c98c153..1c14244 100644
--- a/ft_write_test.c
+++ b/ft_write_test.c
@@ -14,7 +14,7 @@ static int ret;
ret = read(ft_write_pipe[0], buf, FT_WRITE_BUF_SIZE); \
buf[ret] = '\0'; \
if (strcmp(buf, str) != 0) \
- printf("KO: [COMPARE]: %s: expected: \"%s\" got: \"%s\"\n", test_name, str, buf); \
+ printf("KO: [COMPARE]: %s: expected: \"%s\" got: \"%s\"\n", test_name, str, buf); \
else \
print_ok(); \
close(ft_write_pipe[1]); \
diff --git a/libasm_test.h b/libasm_test.h
index 675c5ad..8be0b68 100644
--- a/libasm_test.h
+++ b/libasm_test.h
@@ -13,21 +13,25 @@
# define TO_STRING(x) #x
+# ifdef __linux__
+# define OPEN_MAX FOPEN_MAX
+# endif
+
/*
* mandatory
*/
int
ft_strlen(char *str);
-char
-*ft_strcpy(char *dst, const char *src);
+char*
+ft_strcpy(char *dst, const char *src);
int
ft_strcmp(const char *s1, const char *s2);
int
ft_write(int fildes, const void *buf, size_t buf_size);
int
ft_read(int fildes, void *buf, size_t buf_size);
-char
-*ft_strdup(const char *str);
+char*
+ft_strdup(const char *str);
/*
* bonus
diff --git a/main.c b/main.c
index 8b19230..840d73c 100644
--- a/main.c
+++ b/main.c
@@ -11,9 +11,9 @@ main(void)
ft_strdup_test();
ft_atoi_base_test();
- ft_list_push_front_test();
- ft_list_size_test();
- ft_list_sort_test();
- ft_list_remove_if_test();
+ /* ft_list_push_front_test(); */
+ /* ft_list_size_test(); */
+ /* ft_list_sort_test(); */
+ /* ft_list_remove_if_test(); */
return 0;
}
diff --git a/prettier.py b/prettier.py
index 1b8ad0a..b8f4aab 100644
--- a/prettier.py
+++ b/prettier.py
@@ -34,7 +34,7 @@ def parse():
if line.find("SEGFAULT") != -1:
name = line[4:]
else:
- m = re.search("^KO: \[COMPARE\]: (.*): expected: (.*) got: (.*) (with: .*)?$", line)
+ m = re.search("^KO: \[COMPARE\]: (.*): expected: (.*) got: (.*)( with: .*)?$", line)
if m is None:
print(line)
print("PARSING ERROR")
@@ -51,8 +51,10 @@ def parse():
"type": "COMPARE",
"expected": m.group(2),
"actual": m.group(3),
- "with": m.group(4)[6:]
+ "with": None
})
+ if m.group(4) is not None:
+ l["ko_info"][-1]["with"] = m.group(4)[6:]
if (l["ok_counter"] + l["ko_counter"]) % 15 == 0:
print("\n", ''.join([" " for _ in range(1 + len(name))]), end="")
print(red("[KO] "), end="")
@@ -68,4 +70,7 @@ if __name__ == "__main__":
if e['type'] == "SEGFAULT":
print(f"{k} : {red('SEGFAULT')}")
elif e['type'] == "COMPARE":
- print(f"{k} with {e['with']}:\n {green('expected: ', e['expected'])}\n {red('actual: ', e['actual'])}")
+ p = f"{k}"
+ if e["with"] is not None:
+ p += f"with {e['with']}"
+ print(p, f":\n {green('expected: ', e['expected'])}\n {red('actual: ', e['actual'])}")