Skip to content

Commit 85e9cab

Browse files
authored
Merge pull request jmtth#78 from codastream/fix-make-test-pass
restore tests
2 parents f920cf9 + 7373a18 commit 85e9cab

18 files changed

Lines changed: 70 additions & 41 deletions

File tree

.github/workflows/c-cpp.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
run: make formator
2323
- name: static checks
2424
run: make tidy
25-
#test:
26-
# runs-on: ubuntu-22.04
27-
# steps:
28-
# - uses: actions/checkout@v4
29-
# - name: Install dependencies
30-
# run: sudo apt-get update && sudo apt-get install -y clang-12 make
31-
# - name: build
32-
# run: make -C test
33-
# - name: test
34-
# run: ./test/test
25+
test:
26+
runs-on: ubuntu-22.04
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Install dependencies
30+
run: sudo apt-get update && sudo apt-get install -y clang-12 make
31+
- name: build
32+
run: make -C test
33+
- name: test
34+
run: ./test/test

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ NAME := ircserv
44
OS := $(shell uname)
55

66
CXX := clang++
7-
CXXFLAGS := -Wall -Wextra -Werror -std=c++98 -g -MMD -O0 -fsanitize=address -fno-omit-frame-pointer
8-
LDFLAGS := -no-pie -fsanitize=address
7+
CXXFLAGS := -Wall -Wextra -Werror -std=c++98 -g -MMD
8+
LDFLAGS :=
99
MAKEFLAGS := --no-print-directory
10+
ASANFLAGS := -fsanitize=address -O0 -g
11+
12+
ifeq ($(MAKECMDGOALS),asan)
13+
CXXFLAGS += $(ASANFLAGS)
14+
LDFLAGS += $(ASANFLAGS)
15+
endif
1016

1117
INCLUDES := -Iincludes\
1218
-Iincludes/channels\
@@ -102,7 +108,7 @@ $(OBJ_DIRS) :
102108
@mkdir -p logs
103109

104110
asan : all
105-
ASAN_OPTIONS=detect_leaks=1:log_path=logs/asan.log:atexit_print_stats=true ./ircserv 9999 password
111+
@ASAN_OPTIONS=detect_leaks=1:log_path=logs/asan.log:atexit_print_stats=true ./ircserv 9999 password
106112

107113
forminette:
108114
@echo "$(YELLOW)=== Checking code format ===$(NOC)"
@@ -136,9 +142,6 @@ fclean : clean
136142
re : fclean
137143
@make
138144

139-
run sanitize : all
140-
ASAN_OPTIONS=detect_leaks=1:log_path=asan.log:atexit_print_stats=true ./ircserv 9999 password
141-
142145
.PHONY : all clean fclean re
143146

144147
-include $(DEPS)

codes.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
413=ERR_NOTOPLEVEL:Not a top-level domain
9292
414=ERR_WILDTOPLEVEL:Wildcard in top-level domain
9393
415=ERR_BADMASK:Bad mask
94-
421=ERR_UNKNOWNCOMMAND:Unknown command# Unknown command (sorry guys)
94+
421=ERR_UNKNOWNCOMMAND:Unknown command (sorry guys)
9595
422=ERR_NOMOTD:No message of the day
9696
423=ERR_NOADMININFO:No admin info
9797
424=ERR_FILEERROR:File error

includes/consts.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: fpetit <fpetit@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2025/09/18 23:38:52 by npolack #+# #+# */
9-
/* Updated: 2025/10/08 14:16:13 by fpetit ### ########.fr */
9+
/* Updated: 2025/10/13 23:25:51 by fpetit ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -21,7 +21,7 @@
2121
#define PERM_777 777
2222
#define EPOCH_TIME_START 1900
2323
#define NO_LIMIT (-1)
24-
#define SERVER_NAME "hazardous.irc"
24+
#define SERVER_NAME "hazardous.irc.serv"
2525
#define SERVER_CONF_FILE "irc.conf"
2626
#define SERVER_CONF_FILE_FOR_TEST "../irc.conf"
2727
#define CODES_CONF_FILE "codes.conf"

includes/server/Config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Config
4545
void _set_nickname_max_len(std::string& value);
4646
};
4747
extern const Config ircConfig;
48+
extern const Config ircConfigTest;
4849
extern const Config ircCodes;
4950

5051
#endif

srcs/commands/CmdFactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ICommand* CmdFactory::make_command(Server& server, Client& client, std::string&
102102
return (this->*ptr[i])(server, client, params);
103103
}
104104
}
105-
rh.process_response(client, ERR_UNKNOWNCOMMAND, params);
105+
rh.process_response(client, ERR_UNKNOWNCOMMAND, commandLine);
106106

107107
return NULL;
108108
}

srcs/commands/Kick.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ void Kick::execute(Server& server, Client& client)
148148
validUsers += *nickIt;
149149
channel->remove_member(*targetUser);
150150
std::string messageParam = channel->get_name() + " " + targetUser->get_nickname();
151-
// if (!comment.empty())
152-
// messageParam.append(" :").append(comment);
153-
LOG_dt_CMD("before broadcast");
151+
LOG_d_CMD("before broadcast");
154152
rh.process_response(*targetUser, TRANSFER_KICK, messageParam, &client, comment);
155153
}
156154
}
@@ -159,5 +157,6 @@ void Kick::execute(Server& server, Client& client)
159157
validChans += *chanNamesIt;
160158
broadcastMsg.append(validChans).append(" ").append(validUsers);
161159
channel->broadcast(server, TRANSFER_KICK, broadcastMsg, &client, comment);
160+
rh.process_response(client, TRANSFER_KICK, broadcastMsg, &client, comment);
162161
}
163162
}

srcs/commands/Mode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ ReplyCode Mode::check_args(Server& server, Client& client, std::vector<std::stri
9999
rh.process_response(client, ERR_NEEDMOREPARAMS, "MODE");
100100
return PROCESSED_ERROR;
101101
}
102+
if (modes[i] == 'o' && operation == '-' && i >= modeParams.size()) {
103+
rh.process_response(client, ERR_NEEDMOREPARAMS, "MODE");
104+
return PROCESSED_ERROR;
105+
}
102106
if (modes[i] == 'l' && operation == '+') {
103107
if (modeParams[i].find_first_not_of(digits) != std::string::npos) {
104108
LOG_DV_CMD(modeParams[i]);

srcs/server/Config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
const Config ircConfig(SERVER_CONF_FILE);
1111
const Config ircCodes(CODES_CONF_FILE);
12+
const Config ircConfigTest(SERVER_CONF_FILE_FOR_TEST);
1213

1314
Config::Config() :
1415
_name(SERVER_NAME),

test/include/fakeClient.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
std::unique_ptr<TcpSocket> make_client_socket(int port);
1414
void send_line(const TcpSocket& so, const std::string& msg);
15-
std::string recv_lines(const TcpSocket& so);
15+
std::string recv_lines(const TcpSocket& so, const std::string& nick="");
1616
void do_cmd(const TcpSocket& so, const std::string& msg);
1717

1818
#endif

0 commit comments

Comments
 (0)