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 conf/username.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
your-github-username-here-in-conf-file
Ramananm0
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 "Ramananm0";
}
30 changes: 30 additions & 0 deletions finder-app/finder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Check if both arguments are provided
if [ $# -ne 2 ]; then
echo "Error: Two arguments required."
echo "Usage: $0 <filesdir> <searchstr>"
exit 1
fi
filesdir=$1
searchstr=$2
# Check if filesdir is a directory
if [ ! -d "$filesdir" ]; then
echo "Error: '$filesdir' is not a valid directory."
exit 1
fi
# Count number of files
file_count=$(find "$filesdir" -type f 2>/dev/null | wc -l)
if [ $? -ne 0 ]; then
echo "Error: Failed to count files in '$filesdir'."
exit 1
fi
# Count number of matching lines
match_count=$(grep -r "$searchstr" "$filesdir" 2>/dev/null | wc -l)
if [ $? -ne 0 ]; then
echo "Error: Failed to search files in '$filesdir'."
exit 1
fi

echo "The number of files are $file_count and the number of matching lines are $match_count"
exit 0

26 changes: 26 additions & 0 deletions finder-app/writer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Check if both arguments are provided
if [ $# -ne 2 ]; then
echo "Error: Two arguments required."
echo "Usage: $0 <writefile> <writestr>"
exit 1
fi

writefile=$1
writestr=$2

# Create the directory path if it doesn't exist
dirpath=$(dirname "$writefile")
mkdir -p "$dirpath"
if [ $? -ne 0 ]; then
echo "Error: Failed to create directory '$dirpath'."
exit 1
fi
# Write the string to the file
echo "$writestr" > "$writefile"
if [ $? -ne 0 ]; then
echo "Error: Could not write to file '$writefile'."
exit 1
fi

exit 0
3 changes: 2 additions & 1 deletion student-test/assignment1/Test_validate_username.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ 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!");
TEST_ASSERT_EQUAL_STRING_MESSAGE(my_username(), malloc_username_from_conf_file(), "OK");
//TEST_ASSERT_TRUE_MESSAGE(false,"AESD students, please fix me!");
}