added code to logger-test for comparing WRITE_MESSAGE and decrypted logger output
ma englant gut
This commit is contained in:
parent
3673f24964
commit
b794cab66f
@ -20,15 +20,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
logFile logger = initLogger(WRITE_DIR); //INITIALIZE LOGGER FILE
|
logFile logger = initLogger(WRITE_DIR); //INITIALIZE LOGGER FILE
|
||||||
int bufferSize;
|
|
||||||
char *buffer;
|
|
||||||
char *usedKey = malloc(getKeyLength() + 1);
|
char *usedKey = malloc(getKeyLength() + 1);
|
||||||
FILE *fileBuffer;
|
char **decrypted;
|
||||||
|
int exitCode = 0;
|
||||||
|
|
||||||
//GENERATE KEY
|
//GENERATE KEY
|
||||||
generateKey(usedKey, getKeyLength());
|
generateKey(usedKey, getKeyLength());
|
||||||
@ -44,23 +44,24 @@ int main(void)
|
|||||||
|
|
||||||
writeLog(logger.file, WRITE_MESSAGE); //WRITE
|
writeLog(logger.file, WRITE_MESSAGE); //WRITE
|
||||||
|
|
||||||
fileBuffer = fopen(logger.fileName, "r");
|
decrypted = decryptLogger(logger); //DECRYPT
|
||||||
fseek(fileBuffer, 0, SEEK_END);
|
|
||||||
bufferSize = ftell(fileBuffer);
|
|
||||||
rewind(fileBuffer); //REWIND fileBuffer (NO SHIT)
|
|
||||||
|
|
||||||
//SET LENGTH OF buffer
|
//COMPARE OUTPUT
|
||||||
buffer = calloc(bufferSize + 1, sizeof(buffer)); //CALLOC IS USED BECAUSE OF LE 'Uninitialised value was created by a heap allocation'
|
if (strcmp(decrypted[0], WRITE_MESSAGE) == 0) //SUCCESS
|
||||||
|
{
|
||||||
|
printf("TEST SUCCESSFUL!\n");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "TEST FAILED!\n");
|
||||||
|
exitCode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
//LOAD jsonFile
|
//TODO: Create some function for deallocating decrypted
|
||||||
(void) (fread(buffer, bufferSize, 1, fileBuffer) + 1); //TODO: Try to create some function for processing exit value
|
free(decrypted[0]);
|
||||||
|
free(decrypted);
|
||||||
printf("%s\n", buffer);
|
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
free(buffer);
|
|
||||||
free(usedKey);
|
free(usedKey);
|
||||||
fclose(fileBuffer);
|
|
||||||
deallocateLogger(logger);
|
deallocateLogger(logger);
|
||||||
return 0;
|
return exitCode;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user