Skip to content

Commit 07e57d6

Browse files
committed
asm: init
1 parent 2b95640 commit 07e57d6

File tree

7 files changed

+231
-0
lines changed

7 files changed

+231
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ testframework/v3/libmt_framework.a
2929
testframework/fake_rendu/ft_ls/ft_ls
3030
template_tests/sample_tests*
3131
ft_sh2_tests.out*
32+
libfts_tests*

libftasm_tests/Makefile

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# **************************************************************************** #
2+
# #
3+
# ::: :::::::: #
4+
# Makefile :+: :+: :+: #
5+
# +:+ +:+ +:+ #
6+
# By: yyang <[email protected]> +#+ +:+ +#+ #
7+
# +#+#+#+#+#+ +#+ #
8+
# Created: 2015/01/18 09:55:13 by yyang #+# #+# #
9+
# Updated: 2015/01/25 18:15:17 by yyang ### ########.fr #
10+
# #
11+
# **************************************************************************** #
12+
#
13+
# **************************************************************************** #
14+
15+
#===============================================================================
16+
# REQUIRED CONFIGS
17+
#===============================================================================
18+
19+
# NAME =
20+
# RENDU_PATH_KEY =
21+
22+
#===============================================================================
23+
# DEFAULTS
24+
#===============================================================================
25+
POST_PATTERN = ""
26+
CC_DEBUG = -g
27+
CC_FLAGS = -Werror -Wextra -Wall
28+
29+
FRAMEWORK_PATH = ../testframework/v3/
30+
RENDU_MAKE_ARG = re
31+
CONFIG_INI_PATH = ../config.ini
32+
PATTERN ?= spec.c$$
33+
define FIRST_RULE
34+
make exec_tests
35+
endef
36+
37+
ifeq ("$(RENDU_PATH)", "")
38+
RENDU_PATH ?= $(shell grep $(RENDU_PATH_KEY) $(CONFIG_INI_PATH) | cut -d '=' -f 2 | sed -E "s/^[ \"]*//" | sed -E "s/[ \"]*$$//")
39+
endif
40+
41+
all:
42+
$(FIRST_RULE)
43+
44+
#===============================================================================
45+
# INCLUDES
46+
#===============================================================================
47+
48+
include Makefile_cfg.mk
49+
50+
#===============================================================================
51+
# COMMON
52+
#===============================================================================
53+
TESTS_PATH = tests
54+
CC_LIBFT_LIB_DEFAULT = -L $(LIBFT_PATH) -lft
55+
CC_FRAMEWORK_LIB = -L$(FRAMEWORK_PATH) -lmt_framework
56+
CC_INCLUDES = -I . -I $(FRAMEWORK_PATH)/includes -I $(RENDU_PATH) -I $(RENDU_PATH)/includes -I $(RENDU_PATH)/libft/includes
57+
TEST_FILES = $(shell find tests -name "*.spec.c" -type f -follow -print | grep -e $(PATTERN) | grep -e $(POST_PATTERN))
58+
CC_SOURCE = $(TEST_FILES) main.c utils.c $(CC_SOURCE_EXTRA)
59+
LIBFT_PATH = $(RENDU_PATH)/libft
60+
ADD_TESTS = $(shell echo "$(TEST_FILES)" | perl -pe "s/.*?\/([^\/ ]*)\.spec\.c/MT_ADD_SUITE\(mt, \1, suite_\1); /g")
61+
PROTOTYPES = $(shell echo "$(TEST_FILES)" | perl -pe "s/.*?\/([^\/ ]*)\.spec\.c/MT_ADD_PROTO\(\1\); /g")
62+
CC_DEFINES = -DPROTOTYPES="$(PROTOTYPES)" -DADD_TESTS="$(ADD_TESTS)" -DRENDU_PATH="\"$(RENDU_PATH)\""
63+
64+
exec_tests:
65+
echo "$(TEST_FILES)"
66+
ifneq ("$(wildcard $(RENDU_PATH)/libft/Makefile)","")
67+
make $(RENDU_MAKE_ARG) -k -C $(LIBFT_PATH)
68+
$(eval CC_LIBFT_LIB = $(CC_LIBFT_LIB_DEFAULT))
69+
endif
70+
ifneq ("$(wildcard $(RENDU_PATH)/Makefile)","")
71+
make $(RENDU_MAKE_ARG) -k -C $(RENDU_PATH) $(CC_LIBFT_LIB)
72+
endif
73+
make -k -C $(FRAMEWORK_PATH)
74+
gcc $(CC_FLAGS) $(CC_DEBUG) $(CC_INCLUDES) $(CC_DEFINES) $(CC_SOURCE) -o $(NAME) $(CC_FRAMEWORK_LIB) $(CC_LIBS)
75+
./$(NAME)
76+
77+
clean:
78+
rm -f $(OBJECTS)
79+
80+
fclean: clean
81+
make -k -C $(RENDU_PATH) fclean
82+
make -k -C $(FRAMEWORK_PATH) fclean
83+
rm -f $(NAME)
84+
85+
re: clean fclean all project

libftasm_tests/Makefile_cfg.mk

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
NAME = libfts_tests
2+
RENDU_PATH_KEY = LIBFTASM_PATH
3+
CC_LIBS = -lfts -L $(RENDU_PATH)
4+
5+
override define FIRST_RULE
6+
@make usage
7+
endef
8+
9+
usage:
10+
@echo "Usage:"
11+
@echo "\tmake part1"
12+
@echo "\tmake part2\t--> Also runs part1"
13+
@echo "\tmake bonus\t--> Also runs part1 and part2"
14+
15+
part1_init:
16+
$(eval POST_PATTERN = "00_part1")
17+
part1: part1_init exec_tests
18+
19+
part2_init:
20+
$(eval POST_PATTERN = "\(00_part1\)\|\(01_part2\)")
21+
part2: part2_init exec_tests
22+
23+
bonus_init:
24+
$(eval POST_PATTERN = "")
25+
bonus: bonus_init exec_tests

libftasm_tests/main.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <unistd.h>
2+
#include <string.h>
3+
#include <fw.h>
4+
#include <mt.h>
5+
#include <test.h>
6+
#include <signal.h>
7+
#include <locale.h>
8+
#include "project.h"
9+
10+
PROTOTYPES
11+
12+
13+
int main()
14+
{
15+
t_mt *mt = mt_create("libft");
16+
17+
mt->desc = "Errors should never pass silently! (That's why we don't handle NULL cases.)";
18+
setbuf(stdout, NULL);
19+
20+
ADD_TESTS
21+
22+
mt_exec(mt);
23+
return(0);
24+
}

libftasm_tests/project.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* project.h :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: yyang <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2014/12/05 18:58:31 by celegran #+# #+# */
9+
/* Updated: 2015/02/26 20:33:52 by yyang ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#ifndef PROJECT_H
14+
# define PROJECT_H
15+
16+
# include <fw.h>
17+
# include <string.h>
18+
# include <ctype.h>
19+
# include <stdlib.h>
20+
# include <unistd.h>
21+
22+
char map_test(char c);
23+
char mapi_test(unsigned int i, char c);
24+
void it_test(char *c);
25+
void iti_test(unsigned int i, char *c);
26+
27+
# ifdef BONUS
28+
void del_test(void *data, size_t i);
29+
void lstiter_test(t_list *ppp);
30+
t_list *lstmap_test(t_list *list);
31+
# endif
32+
33+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include <project.h>
2+
3+
int ft_isdigit(int i);
4+
5+
#define mt_test_isdigit(test_name, tested_char) \
6+
static void test_## test_name(t_test *test) \
7+
{ \
8+
mt_assert(ft_isdigit(tested_char) == isdigit(tested_char)); \
9+
}
10+
11+
mt_test_isdigit(num1, 'a');
12+
mt_test_isdigit(num2, 'a' + 0x100);
13+
mt_test_isdigit(num3, '2');
14+
mt_test_isdigit(num4, 'Z');
15+
mt_test_isdigit(num5, 't');
16+
mt_test_isdigit(num6, 0);
17+
mt_test_isdigit(num7, 1);
18+
mt_test_isdigit(num8, 9999);
19+
mt_test_isdigit(num9, '1');
20+
mt_test_isdigit(num10, '2');
21+
mt_test_isdigit(num11, 'A');
22+
mt_test_isdigit(num12, 'Z');
23+
mt_test_isdigit(num13, ' ');
24+
mt_test_isdigit(num14, '%');
25+
mt_test_isdigit(num15, '\t');
26+
mt_test_isdigit(num16, '\n');
27+
mt_test_isdigit(num17, '\v');
28+
mt_test_isdigit(num18, '\b');
29+
mt_test_isdigit(num19, 7);
30+
mt_test_isdigit(num20, '0');
31+
mt_test_isdigit(num21, '0' - 1);
32+
mt_test_isdigit(num22, '9');
33+
mt_test_isdigit(num23, '9' + 1);
34+
mt_test_isdigit(num24, -1);
35+
36+
void suite_00_part1_ft_isdigit(t_suite *suite)
37+
{
38+
SUITE_ADD_TEST(suite, test_num1);
39+
SUITE_ADD_TEST(suite, test_num2);
40+
SUITE_ADD_TEST(suite, test_num3);
41+
SUITE_ADD_TEST(suite, test_num4);
42+
SUITE_ADD_TEST(suite, test_num5);
43+
SUITE_ADD_TEST(suite, test_num6);
44+
SUITE_ADD_TEST(suite, test_num7);
45+
SUITE_ADD_TEST(suite, test_num8);
46+
SUITE_ADD_TEST(suite, test_num9);
47+
SUITE_ADD_TEST(suite, test_num10);
48+
SUITE_ADD_TEST(suite, test_num11);
49+
SUITE_ADD_TEST(suite, test_num12);
50+
SUITE_ADD_TEST(suite, test_num13);
51+
SUITE_ADD_TEST(suite, test_num14);
52+
SUITE_ADD_TEST(suite, test_num15);
53+
SUITE_ADD_TEST(suite, test_num16);
54+
SUITE_ADD_TEST(suite, test_num17);
55+
SUITE_ADD_TEST(suite, test_num18);
56+
SUITE_ADD_TEST(suite, test_num19);
57+
SUITE_ADD_TEST(suite, test_num20);
58+
SUITE_ADD_TEST(suite, test_num21);
59+
SUITE_ADD_TEST(suite, test_num22);
60+
SUITE_ADD_TEST(suite, test_num23);
61+
SUITE_ADD_TEST(suite, test_num24);
62+
63+
}

libftasm_tests/utils.c

Whitespace-only changes.

0 commit comments

Comments
 (0)