Add valgrind testing and fix valgrind errors
This commit is contained in:
parent
f45418cdd9
commit
f34980c67b
@ -1,5 +1,5 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Assignment1" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment1" TARGET_NAME="Assignment1" CONFIG_NAME="RelWithDebInfo-WSL" RUN_TARGET_PROJECT_NAME="Assignment1" RUN_TARGET_NAME="Assignment1">
|
||||
<configuration default="false" name="Assignment1" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment1" TARGET_NAME="Assignment1" CONFIG_NAME="RelWithDebInfo" RUN_TARGET_PROJECT_NAME="Assignment1" RUN_TARGET_NAME="Assignment1">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
|
@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Assignment1 Valgrind" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="true" REDIRECT_INPUT_PATH="$PROJECT_DIR$/tests/pdf2.txt" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment1" TARGET_NAME="Assignment1" CONFIG_NAME="RelWithDebInfo" RUN_TARGET_PROJECT_NAME="Assignment1" RUN_TARGET_NAME="Assignment1">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,5 +1,5 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="For Testing" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="true" REDIRECT_INPUT_PATH="$PROJECT_DIR$/tests/exit.txt" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment1" TARGET_NAME="Assignment1" CONFIG_NAME="RelWithDebInfo-WSL" RUN_TARGET_PROJECT_NAME="Assignment1" RUN_TARGET_NAME="Assignment1">
|
||||
<configuration default="false" name="For Testing" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="true" REDIRECT_INPUT_PATH="$PROJECT_DIR$/tests/exit.txt" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment1" TARGET_NAME="Assignment1" CONFIG_NAME="RelWithDebInfo" RUN_TARGET_PROJECT_NAME="Assignment1" RUN_TARGET_NAME="Assignment1">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Test" type="ShConfigurationType">
|
||||
<option name="SCRIPT_TEXT" value="wsl ./test.sh" />
|
||||
<option name="SCRIPT_TEXT" value="wsl -d RockyLinux ./test.sh" />
|
||||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
||||
<option name="SCRIPT_PATH" value="" />
|
||||
<option name="SCRIPT_OPTIONS" value="" />
|
||||
@ -13,7 +13,7 @@
|
||||
<option name="EXECUTE_SCRIPT_FILE" value="false" />
|
||||
<envs />
|
||||
<method v="2">
|
||||
<option name="RunConfigurationTask" enabled="false" run_configuration_name="For Testing" run_configuration_type="CMakeRunConfiguration" run_configuration_target="CMakeBuildProfile:RelWithDebInfo-WSL" />
|
||||
<option name="RunConfigurationTask" enabled="false" run_configuration_name="For Testing" run_configuration_type="CMakeRunConfiguration" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
19
Assignment1/.idea/runConfigurations/Valgrind.xml
Normal file
19
Assignment1/.idea/runConfigurations/Valgrind.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Valgrind" type="ShConfigurationType">
|
||||
<option name="SCRIPT_TEXT" value="wsl -d RockyLinux ./valgrind.sh" />
|
||||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
||||
<option name="SCRIPT_PATH" value="" />
|
||||
<option name="SCRIPT_OPTIONS" value="" />
|
||||
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="false" />
|
||||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
|
||||
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
||||
<option name="INTERPRETER_PATH" value="" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="EXECUTE_IN_TERMINAL" value="true" />
|
||||
<option name="EXECUTE_SCRIPT_FILE" value="false" />
|
||||
<envs />
|
||||
<method v="2">
|
||||
<option name="RunConfigurationTask" enabled="false" run_configuration_name="For Testing" run_configuration_type="CMakeRunConfiguration" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -6,7 +6,6 @@
|
||||
|
||||
#define MAX_LEN 100
|
||||
|
||||
|
||||
Node *search(Node **head, char *data) {
|
||||
Node *current = *head;
|
||||
while (current != NULL) {
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by Isaac on 9/15/2023.
|
||||
//
|
||||
|
||||
#ifndef ASSIGNMENT1_LINKED_LIST_H
|
||||
#define ASSIGNMENT1_LINKED_LIST_H
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
//
|
||||
// Created by Isaac on 9/15/2023.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "linked_list.h"
|
||||
|
||||
|
||||
#define MAX_LEN 100
|
||||
|
||||
int main() {
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by Isaac on 9/15/2023.
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -16,7 +12,7 @@ Node *createNode(char *data) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Allocate memory for the data, and check if it was successful
|
||||
node->data = calloc(strlen(data), sizeof(char));
|
||||
node->data = calloc(strlen(data) + 1, sizeof(char));
|
||||
if (node->data == NULL) {
|
||||
printf("Error allocating memory for node data\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@ -38,7 +34,7 @@ void destroyNode(Node *node) {
|
||||
void replaceData(Node *node, char *data) {
|
||||
// Free the data first, then allocate memory for the new data
|
||||
free(node->data);
|
||||
node->data = calloc(strlen(data), sizeof(char));
|
||||
node->data = calloc(strlen(data) + 1, sizeof(char));
|
||||
if (node->data == NULL) {
|
||||
printf("Error allocating memory for replacing data\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -1,7 +1,3 @@
|
||||
//
|
||||
// Created by Isaac on 9/15/2023.
|
||||
//
|
||||
|
||||
#ifndef ASSIGNMENT1_NODE_H
|
||||
#define ASSIGNMENT1_NODE_H
|
||||
typedef struct node {
|
||||
|
8
Assignment1/tests/valgrind.sh
Normal file
8
Assignment1/tests/valgrind.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Could make more complicated and more similar to test.sh, but only the most complicated test case is fine for now
|
||||
|
||||
valgrind --leak-check=full \
|
||||
--show-leak-kinds=definite \
|
||||
--track-origins=yes \
|
||||
./../build/Assignment1 < pdf2.txt
|
Loading…
Reference in New Issue
Block a user