Skip to content

Commit

Permalink
chore: removed broken testers
Browse files Browse the repository at this point in the history
  • Loading branch information
Taanviir committed Jun 11, 2024
1 parent 37de085 commit dbe1315
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 292 deletions.
21 changes: 6 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ clean:
$(RM) $(OBJS_DIR); \
echo "$(RED)$(BOLD)[ DELETE ]$(RESET) Removed object files."; \
fi
@if [ -f $(TEST_PARSER) ] || [ -f $(TEST_HTTP) ] || [ -f $(TEST_SOCKET) ] || [ -f $(TEST_CGI) ] || [ -f client ]; then \
$(RM) $(TEST_PARSER) $(TEST_HTTP) $(TEST_SOCKET) $(TEST_CGI) client; \
@if [ -f $(TEST_PARSER) ] || [ -f $(TEST_SOCKET) ] [ -f client ]; then \
$(RM) $(TEST_PARSER) $(TEST_SOCKET) client; \
echo "$(RED)$(BOLD)[ DELETE ]$(RESET) Removed testers."; \
fi

Expand All @@ -92,23 +92,14 @@ re: fclean
test_parser:
@cd ./$(PARSER_DIR)/$(TESTS_DIR) && ./run_tests.sh && cd -

test_http:
@$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(CGI_SRCS) $(HTTP_SRCS) $(TEST_HTTP_SRC) -o $(TEST_HTTP)
@echo "$(BLUE)$(BOLD)[ TEST ]$(RESET) HTTP ready for testing."

#! SOCKET_main.cpp has a compile error so this test has been commented out
# test_socket:
# @$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(SOCKET_SRCS) $(TEST_CLIENT_SRC) -o $(SERVER_DIR)/client @$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(SOCKET_SRCS) $(TEST_SOCKET_SRC) -o $(TEST_SOCKET)
# @echo "$(BLUE)$(BOLD)[ TEST ]$(RESET) SOCKET ready for testing."
test_socket:
@$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(SOCKET_SRCS) $(TEST_CLIENT_SRC) -o $(SERVER_DIR)/client @$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(SOCKET_SRCS) $(TEST_SOCKET_SRC) -o $(TEST_SOCKET)
@echo "$(BLUE)$(BOLD)[ TEST ]$(RESET) SOCKET ready for testing."

client: $(TEST_CLIENT_SRC)
@$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(TEST_CLIENT_SRC) $(SERVER_DIR)/socket/Socket.cpp $(SERVER_DIR)/socket/TCPSocket.cpp -o $@
@echo "$(BLUE)$(BOLD)[ TEST ]$(RESET) Client is ready."

test_cgi:
@$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(SANITIZE) $(HTTP_SRCS) $(CGI_SRCS) $(TEST_CGI_SRC) -o $(TEST_CGI)
@echo "$(BLUE)$(BOLD)[ TEST ]$(RESET) CGI ready for testing."

format:
@echo "$(BLUE)$(BOLD)[ FORMAT ]$(RESET) Formatting code..."
@find . -name "*.cpp" -exec clang-format -i {} +
Expand All @@ -117,4 +108,4 @@ format:

-include $(OBJS:.o=.d)

.PHONY: all run log debug clean fclean re test_parser test_http test_socket client test_cgi format
.PHONY: all run log debug clean fclean re test_parser test_socket client format
99 changes: 0 additions & 99 deletions sources/CGI/.tests/test_cgi.cpp

This file was deleted.

4 changes: 0 additions & 4 deletions sources/CGI/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@

CGI_SRCS:= $(addprefix $(CGI_DIR)/, CGI.cpp)
SRCS += $(CGI_SRCS)

# tester mains
TEST_CGI:= $(CGI_DIR)/test_cgi
TEST_CGI_SRC:= $(CGI_DIR)/$(TESTS_DIR)/test_cgi.cpp
39 changes: 0 additions & 39 deletions sources/http/.tests/test_http.cpp

This file was deleted.

68 changes: 0 additions & 68 deletions sources/http/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,72 +160,4 @@ static StatusCodeMap createStatusCodeMap()

const StatusCodeMap status_codes_map = createStatusCodeMap();

/* ------------------------------ HTTP SAMPLES ------------------------------ */

static const string sample_response =
"HTTP/1.1 200 OK\r\n" // status line
"Content-Type: text/html; charset=UTF-8\r\n" // headers
"Content-Length: 23\r\n"
"\r\n"
"<html>\r\n"
"<head><title>Sample Page</title></head>\r\n"
"<body><h1>Hello, World!</h1><p>This is a sample webpage.</p></body>\r\n"
"</html>\r\n";


static const string sample_request =
"GET resource/resource HTTP/1.1\r\n" // request-line
"Host: Linode.com\r\n" // headers fields
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.8) "
"Gecko/20091102 Firefox/3.5.5 \r\n"
"Content-Length: 69\r\n"
"Transfer-Encoding: chunked\r\n"
"Accept-Charset: ISO-8859-1,utf-8\r\n"
"Cache-Control: no-cache\r\n"
"\r\n" //
"17\r\n"
"Wiki aldkjflakdjf w kew\r\n"
"17\r\n"
"Wiki aldkjflakdjf w kew\r\n"
"17\r\n"
"Wiki aldkjflakdjf w kew\r\n"
"0\r\n"
"\r\n"
"Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit\r\n"
"enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet.\r\n"
"Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem\r\n"
"est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud\r\n"
"officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat "
"reprehenderit\r\n"
"commodo officia dolor Lorem duis laboris cupidatat officia voluptate.\r\n"
"Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia "
"eiusmod.\r\n"
"Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim.\r\n"
"Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa "
"duis.\r\n"
"\r\n";

static const string sample_request_cgi =
"GET /Users/hashim/Desktop/42curses/webserv/sources/CGI/.tests/file.sh?name=hashim&lastname=mohamed HTTP/1.1\r\n" // request-line
"Host: Linode.com\r\n" // headers fields
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.8) "
"Gecko/20091102 Firefox/3.5.5 \r\n"
"Accept-Encoding: gzip,deflate\r\n"
"Accept-Charset: ISO-8859-1,utf-8\r\n"
"Cache-Control: no-cache\r\n"
"\r\n" //
"Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit\r\n"
"enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet.\r\n"
"Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem\r\n"
"est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud\r\n"
"officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat "
"reprehenderit\r\n"
"commodo officia dolor Lorem duis laboris cupidatat officia voluptate.\r\n"
"Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia "
"eiusmod.\r\n"
"Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim.\r\n"
"Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa "
"duis.\r\n"
"\r\n";

#endif // MESSAGE_HPP
2 changes: 1 addition & 1 deletion sources/http/handler/DeleteRequestHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "DeleteRequestHandler.hpp"
#include "CachedPages.hpp"
#include "CGI.hpp"
#include "CachedPages.hpp"

Response DeleteRequestHandler::handle_request(const Request& r)
{
Expand Down
2 changes: 1 addition & 1 deletion sources/http/handler/GetRequestHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "GetRequestHandler.hpp"
#include "CachedPages.hpp"
#include "CGI.hpp"
#include "CachedPages.hpp"
#include "webserv.hpp"

Response GetRequestHandler::handle_request(const Request& r)
Expand Down
4 changes: 0 additions & 4 deletions sources/http/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ HANDLER_DIR:=$(HTTP_DIR)/handler
HANDLER_SRCS:= $(wildcard $(HANDLER_DIR)/*.cpp)

SRCS += $(REQUEST_SRCS) $(RESPONSE_SRCS) $(HANDLER_SRCS) $(wildcard ./*cpp)

# tester mains
TEST_HTTP:= $(HTTP_DIR)/test_http
TEST_HTTP_SRC:= $(HTTP_DIR)/$(TESTS_DIR)/test_http.cpp
23 changes: 21 additions & 2 deletions sources/server/.tests/ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@
#include <arpa/inet.h>
#include <unistd.h>

const string crlf("\r\n");
const string request("GET /index.html " + HTTP_VER + crlf + crlf);
#define BUFFER_SIZE 4096

static const string sample_request =
"GET resource/resource HTTP/1.1\r\n" // request-line
"Host: Linode.com\r\n" // headers fields
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.8) "
"Gecko/20091102 Firefox/3.5.5 \r\n"
"Content-Length: 69\r\n"
"Transfer-Encoding: chunked\r\n"
"Accept-Charset: ISO-8859-1,utf-8\r\n"
"Cache-Control: no-cache\r\n"
"\r\n" //
"17\r\n"
"Wiki aldkjflakdjf w kew\r\n"
"17\r\n"
"Wiki aldkjflakdjf w kew\r\n"
"17\r\n"
"Wiki aldkjflakdjf w kew\r\n"
"0\r\n"
"\r\n"
"Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit\r\n"
"\r\n";

int main()
{
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
Expand Down
Loading

0 comments on commit dbe1315

Please sign in to comment.