Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update autotest-validate.c #47

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
23 changes: 23 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: C/C++ CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: configure
run: ./configure
- name: make
run: make
- name: make check
run: make check
- name: make distcheck
run: make distcheck
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
abraham5500
3 changes: 2 additions & 1 deletion examples/autotest-validate/autotest-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ bool this_function_returns_false()
*/
const char *my_username()
{
return "todo-please-enter-your-username-here-in-my_username";
// return "todo-please-enter-your-username-here-in-my_username";
return "abraham5500";
}
29 changes: 29 additions & 0 deletions finder-app/finder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# Check if both arguments are provided
if [ "$#" -ne 2 ]; then
echo "Error: Two arguments are required."
echo "Usage: $0 <filesdir> <searchstr>"
exit 1
fi

# Assign arguments to variables
filesdir=$1
searchstr=$2

# Check if filesdir is a directory
if [ ! -d "$filesdir" ]; then
echo "Error: $filesdir is not a directory"
exit 1
fi

# Count the number of files in the directory and its subdirectories
num_files=$(find "$filesdir" -type f | wc -l)

# Count the number of matching lines in those files
num_matching_lines=$(grep -r "$searchstr" "$filesdir" 2>/dev/null | wc -l)

# Print the result
echo "The number of files are $num_files and the number of matching lines are $num_matching_lines"

exit 0
32 changes: 32 additions & 0 deletions finder-app/writer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

# Check if both arguments are provided
if [ "$#" -ne 2 ]; then
echo "Error: Two arguments are required."
echo "Usage: $0 <writefile> <writestr>"
exit 1
fi

# Assign arguments to variables
writefile=$1
writestr=$2

# Extract the directory path from the file path
writedir=$(dirname "$writefile")

# Create the directory path if it doesn't exist
mkdir -p "$writedir"
if [ $? -ne 0 ]; then
echo "Error: Could not create directory $writedir"
exit 1
fi

# Write the string to the file, overwriting any existing file
echo "$writestr" > "$writefile"
if [ $? -ne 0 ]; then
echo "Error: Could not write to file $writefile"
exit 1
fi

echo "File $writefile created with content: $writestr"
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_TRUE_MESSAGE(false,"AESD students, please fix me!");
TEST_ASSERT_EQUAL_STRING_MESSAGE(my_username(),malloc_username_from_conf_file(),"Passed");
}