Skip to content
Permalink
Browse files
Set up testing framework for brutus and future code
  • Loading branch information
csx239 committed Oct 7, 2020
1 parent 058239c commit f53349168d443a0fa3049f2cd7dcc665c7400276
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
@@ -1,2 +1,5 @@
*~
/dictionaries/reductor.py
/brute_venv/
/html/
/src/__pycache__/
@@ -0,0 +1,30 @@
VENV=brute_venv
INVENV = $(shell pip3 -V | grep $(VENV))
current_dir = $(shell pwd)

prereqs: venvcheck FORCE
pip install -r requirements.txt

venv: FORCE
python3 -m venv $(VENV)

docs:
pdoc --html ./src/brutus.py --force

venvcheck:
ifeq ($(INVENV),)
$(error You should only run this from within the venv. Use '. ./$(VENV)/bin/activate')
else
@echo "venv check passed\n"
endif

test/testbin: test/testbin.c
$(CC) -o test/testbin test/testbin.c

test: FORCE venvcheck test/testbin
py.test -v tests/




FORCE:
@@ -0,0 +1,3 @@
pdoc3
pytest
pexpect
@@ -21,7 +21,7 @@ class Binary:
""" Reads data from the standard output of the binary.
Returns:
None: if there is no data
A string containing the next line of output if available."""
A String: containing the next line of output if available."""
if self.proc.eof():
return None
return self.proc.readline()
@@ -0,0 +1,8 @@
import pytest
import sys
sys.path.append("./src/")

import brutus

# You can import your source files here, too
# So you can test the functions you create
BIN +8.38 KB test/testbin
Binary file not shown.
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>

int main(void)
{
char* actualPw = "swordfish"; //Of course
char guess[20];
printf ("Enter the password: ");
fgets ( guess, 80, stdin );

//Strip the \n, replace with 0
guess[strcspn(guess, "\n")] = 0;
printf("You entered [%s]\n",guess);
if(strcmp(guess,actualPw)==0){
printf("Password Correct\n");
}else{
printf("Password Incorrect\n");
}
}

0 comments on commit f533491

Please sign in to comment.