Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Run unit test
run: ./unit-test.sh
full-test:
container: cuaesd/aesd-autotest:assignment1
container: cuaesd/aesd-autotest:assignment2
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ project(aesd-assignments)
set(AUTOTEST_SOURCES
test/assignment1/Test_hello.c
test/assignment1/Test_assignment_validate.c
../student-test/assignment1/Test_validate_username.c
)
# A list of all files containing test code that is used for assignment validation
set(TESTED_SOURCE
Expand Down
4 changes: 4 additions & 0 deletions assignments/assignment2/cross-compile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/11/lto-wrapper
/
1 change: 1 addition & 0 deletions assignments/assignment2/fileresult.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
writer: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=5dbecdf093d245d450bbe922259abd0281ef28d9, for GNU/Linux 3.7.0, with debug_info, not stripped
2 changes: 1 addition & 1 deletion conf/assignment.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
assignment1
assignment2
2 changes: 1 addition & 1 deletion conf/username.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
your-github-username-here-in-conf-file
haimts
2 changes: 1 addition & 1 deletion examples/autotest-validate/autotest-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ bool this_function_returns_false()
*/
const char *my_username()
{
return "todo-please-enter-your-username-here-in-my_username";
return "haimts";
}
9 changes: 9 additions & 0 deletions finder-app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CC=gcc
CFLAGS=-g -Wall
all: writer writer.o writer.c
writer: writer.o
$(CROSS_COMPILE)$(CC) $< -o $@
writer.o: writer.c
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@
clean:
rm writer.o writer
2 changes: 1 addition & 1 deletion finder-app/finder-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi

for i in $( seq 1 $NUMFILES)
do
./writer.sh "$WRITEDIR/${username}$i.txt" "$WRITESTR"
./writer "$WRITEDIR/${username}$i.txt" "$WRITESTR"
done

OUTPUTSTRING=$(./finder.sh "$WRITEDIR" "$WRITESTR")
Expand Down
18 changes: 18 additions & 0 deletions finder-app/finder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
filesdir=$1
searchstr=$2
if [ $# -ne 2 ]
then
echo must specify serch dir and tooken
exit 1
fi
if [ -d $1 ]
then
fileslist=$( ls -1 $filesdir )
filesCount=$( ls -1 $filesdir | wc -l )
searchInFilesCount=$( grep -r "$searchstr" $filesdir 2>/dev/null |wc -l )
echo The number of files are $filesCount and the number of matching lines are $searchInFilesCount
else
echo $1 not seems to be a directory
exit 1
fi
41 changes: 41 additions & 0 deletions finder-app/writer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdint.h>
#include <syslog.h>
#include <errno.h>
#include <string.h>

int main(int argc, char * argv[], char * envp[])
{
FILE * newFileToWrite;
size_t rc;
openlog(NULL, 0, LOG_USER);
if (argc != 3)
{
syslog(LOG_ERR, "Must specify exactly two argument!\n");
closelog();
return 1;
}
newFileToWrite = fopen(argv[1],"w");
if (newFileToWrite == NULL || argv[1] == NULL || argv[2] == NULL)
{
syslog(LOG_ERR, "Unable to create file %s, %s\n", argv[1], strerror(errno));
closelog();
return 1;
}

rc = fwrite(argv[2], sizeof(char), strlen(argv[2]), newFileToWrite);
if (rc != sizeof(char) * strlen(argv[2]))
{
syslog(LOG_ERR, "Unable to write string properaly\n");
closelog();
fclose(newFileToWrite);
return 1;
}


syslog(LOG_INFO, "Writing %s to %s\n", argv[2], argv[1]);
closelog();
fclose(newFileToWrite);

return 0;
}
27 changes: 27 additions & 0 deletions finder-app/writer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
newfilename=$1
strtoinsert=$2
if [ $# -ne 2 ]
then
echo "need to specify both argument"
exit 1
fi
mkdir -p $( dirname $newfilename)
if [ $? -ne 0 ]
then
echo "can\'t create file path"
exit 1
fi
touch $newfilename
if [ -w $newfilename ]
then
if [ $? -ne 0 ] || [ -d $newfilename ]
then
echo "can\'t create file $newfilename"
exit 1
fi
echo $strtoinsert > $newfilename
else
echo "$newfilename is not writable"
exit 1
fi
8 changes: 5 additions & 3 deletions student-test/assignment1/Test_validate_username.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

/**
* This function should:
* 1) Call the my_username() function in autotest-validate.c to get your hard coded username.
* 1) Call the my_username() function in Test_assignment_validate.c to get your hard coded username.
* 2) Obtain the value returned from function malloc_username_from_conf_file() in username-from-conf-file.h within
* the assignment autotest submodule at assignment-autotest/test/assignment1/
* 3) Use unity assertion TEST_ASSERT_EQUAL_STRING_MESSAGE to verify the two strings are equal. See
* 3) Use unity assertion TEST_ASSERT_EQUAL_STRING_MESSAGE the two strings are equal. See
* the [unity assertion reference](https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityAssertionsReference.md)
*/
void test_validate_my_username()
Expand All @@ -18,5 +18,7 @@ void test_validate_my_username()
* TODO: Replace the line below with your code here as described above to verify your /conf/username.txt
* config file and my_username() functions are setup properly
*/
TEST_ASSERT_TRUE_MESSAGE(false,"AESD students, please fix me!");
const char * name = my_username();
char * confName = malloc_username_from_conf_file();
TEST_ASSERT_EQUAL_STRING_MESSAGE(name, confName,"Git User Name does't match!");
}