-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
#include "../include/ringbuf.h" | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/types.h> | ||
|
||
void ringbuffer_init(rbctx_t *context, void *buffer_location, size_t buffer_size) | ||
{ | ||
/* your solution here */ | ||
void ringbuffer_init(rbctx_t *context, void *buffer_location, | ||
size_t buffer_size) { | ||
context->begin = (uint8_t *)buffer_location; | ||
context->end = context->begin + buffer_size; | ||
context->read = context->begin; | ||
context->write = context->begin; | ||
} | ||
|
||
int ringbuffer_write(rbctx_t *context, void *message, size_t message_len) | ||
{ | ||
/* your solution here */ | ||
} | ||
int ringbuffer_write(rbctx_t *context, void *message, size_t message_len) { | ||
if (message_len >= context->end - context->begin) { | ||
return OUTPUT_BUFFER_TOO_SMALL; | ||
} | ||
|
||
int ringbuffer_read(rbctx_t *context, void *buffer, size_t *buffer_len) | ||
{ | ||
/* your solution here */ | ||
for (size_t i = 1; i <= message_len; i++) { | ||
context->begin[i] = ((char *)message)[i]; | ||
context->write += 1; | ||
} | ||
return SUCCESS; | ||
} | ||
|
||
void ringbuffer_destroy(rbctx_t *context) | ||
{ | ||
/* your solution here */ | ||
int ringbuffer_read(rbctx_t *context, void *buffer, size_t *buffer_len) { | ||
/* your solution here */ | ||
} | ||
|
||
void ringbuffer_destroy(rbctx_t *context) { /* your solution here */ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
make clean | ||
make all | ||
|
||
# Initialize counters | ||
passed=0 | ||
failed=0 | ||
summary_file=$(mktemp) | ||
|
||
# Iterate over the test executables | ||
for test_executable in $(find build/ -type f \( -name "test" -o -name "test_*" \)); do | ||
if [ -x "$test_executable" ]; then | ||
echo -e "\n===> \033[0;34mRUNNING\033[0m $test_executable <===\n" | ||
"$test_executable" | ||
if [ $? -eq 0 ]; then | ||
echo "echo -e \"\033[0;32mPASSED\033[0m --- $test_executable\"" >> $summary_file | ||
passed=$((passed+1)) | ||
else | ||
echo "echo -e \"\033[0;31mFAILED\033[0m --- $test_executable\"" >> $summary_file | ||
failed=$((failed+1)) | ||
fi | ||
fi | ||
done | ||
|
||
total=$((passed + failed)) | ||
|
||
echo -e "===SUMMARY===\n" | ||
|
||
source $summary_file | ||
rm -rf $summary_file | ||
|
||
echo "---" | ||
|
||
if [ $failed -ne 0 ]; then | ||
echo -e "\033[0;31mFAILED:\033[0m $failed / $total" | ||
fi | ||
if [ $passed -ne 0 ]; then | ||
echo -e "\033[0;32mPASSED:\033[0m $passed / $total" | ||
fi | ||
|
||
exit $failed |