Skip to content

Commit

Permalink
Update progress notifier lab
Browse files Browse the repository at this point in the history
Signed-off-by: Obed N Munoz <[email protected]>
  • Loading branch information
obedmr committed Sep 29, 2020
1 parent 9a2fbdf commit 9c104b9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 15 deletions.
1 change: 1 addition & 0 deletions labs/progress-notifier/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

include ../../common.mk
-include lab.mk
39 changes: 24 additions & 15 deletions labs/progress-notifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ Lab - Progress Notifier with Signals
Implement a program for encoding and decoding files by using the `Base64` [algorithm](https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64).
You're free to copy from previous link's implementation (don't forget to reference to the author's page), the interesting part will be the implementation of signal handlers for progress status.

Add one or multiple signal handlers to catch the `SIGUSR1` and `SIGINT`. Once a signal is catched, your program should dislay the current progress of the encoding or deconding tasks.
Add one or multiple signal handlers to catch the `SIGUSR1` and `SIGINT`. Once a signal is catched, your program should display the current progress of the encoding or deconding tasks.

You will need the proper mechanisms for tracking the progress of any encoding/decoding task. You program must support plain text input files.


Encoding
--------
```
./base64 --encode input.txt
```
Your program should generate a new `encoded.txt` file with the result.
Your program should generate a new `input-encoded.txt` file with the result. The encoded file name must have the following naming convention `<input-file>-encoded.txt`.


Decoding
--------
Expand All @@ -21,6 +23,7 @@ Decoding
```
Your program will generate a `decoded.txt` file witg the result.


How to test?
------------
- Get process ID
Expand All @@ -34,19 +37,6 @@ kill -SIGINT <PID>
kill -SIGINFO <PID>
```


Test files
----------
- [vgilante.txt](http://textfiles.com/stories/vgilante.txt)
- [sick-kid.txt](http://textfiles.com/stories/sick-kid.txt)
- [aesop11.txt](http://textfiles.com/stories/aesop11.txt)

**NOTE:** In case that your program is super fast, create a bigger file to make it take more time to process.
```
# This command will generate a ~1Gb bix.txt file
head -c 1073741824 </dev/urandom >big.txt
```

General Requirements and Considerations
---------------------------------------
- Use the logger that was done on [advanced-logger](https://github.com/CodersSquad/ap-labs/tree/master/labs/advanced-logger).
Expand All @@ -56,9 +46,28 @@ General Requirements and Considerations
- Don't forget to handle errors properly.
- Coding best practices implementation will be also considered.


Test Suite
----------
Build and Test automation is already implemented with the following command. Below some general tips and comments.

- Make sure that your program passes all test cases without errors.
- Remember that this is being executed by a robot script.
- You cannot edit the `lab.mk` file.
- Failed compilation or segmentation faults means 0-graded.
- Failed tests without proper handling will be properly discounted from total grade.

```
make test
```


How to submit your work and check your submission
=================================================
```
# Clean binaries and temporal test files
make clean
# Submit
GITHUB_USER=<your_github_user> make submit
Expand Down
34 changes: 34 additions & 0 deletions labs/progress-notifier/lab.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# word-reverser build & test automation

APP_NAME=base64
LIB_NAME=logger

build:
gcc -c ${APP_NAME}.c -o ${APP_NAME}.o
gcc -c ${LIB_NAME}.c -o ${LIB_NAME}.o
gcc ${LIB_NAME}.o ${APP_NAME}.o -o ${APP_NAME}

files:
curl -Ok http://textfiles.com/stories/vgilante.txt
curl -Ok http://textfiles.com/stories/sick-kid.txt
curl -Ok http://textfiles.com/stories/aesop11.txt
head -c 2147483648 </dev/urandom > megafile.txt

test: build files
@echo Test 1
./${APP_NAME} --encode vigilante.txt
./${APP_NAME} --decode vigilante-encoded.txt
@echo Test 2
./${APP_NAME} --encode sick-kid.txt
./${APP_NAME} --decode sick-kid-encoded.txt
@echo Test 3
./${APP_NAME} --encode aesop11.txt
./${APP_NAME} --decode aesop11-encoded.txt
@echo Test 4 - megafile - 2 Gb
./${APP_NAME} --encode megafile.txt
./${APP_NAME} --decode megafile-encoded.txt
@echo Test 5 - failed test
./${APP_NAME} --decode non-existing-file.txt

clean:
rm -rf *.o ${APP_NAME} *-encoded.txt vgilante.txt sick-kid.txt aesop11.txt megafile.txt

0 comments on commit 9c104b9

Please sign in to comment.