Skip to content

This project is part of the Programming Fundamental course @ CECS KMITL

Notifications You must be signed in to change notification settings

txasw/csv-cooking

Repository files navigation

System Testing Data Manager

A lightweight C application for managing system testing data records with full CRUD operations, search functionality, data recovery features, and comprehensive test suites.

✨ Features

  • CRUD Operations: Create, Read, Update, Delete test records
  • Search & Filter: Search across all record fields with pagination
  • Data Recovery: Soft delete with recovery options
  • Input Validation: Robust validation for all user inputs
  • Cross-platform: Windows, Linux, and macOS support
  • Memory Safe: Comprehensive memory management and testing
  • Modular Design: Separated unit tests and E2E tests
  • Automated Testing: Built-in unit tests and end-to-end tests

📁 Project Structure

testdata-manager/
├── main.h              # Main header file with declarations
├── main.c              # Core application logic
├── unit_tests.h        # Unit test declarations
├── unit_tests.c        # Unit test implementations
├── e2e_tests.h         # E2E test declarations
├── e2e_tests.c         # E2E test implementations
├── Makefile            # Build automation
├── HOW_TO_COMPILE.md   # Comprehensive compilation guide (Thai)
├── README.md           # This file
└── .gitignore          # Git ignore rules

🚀 Quick Start

Prerequisites

  • Compiler: GCC (MinGW on Windows) or Clang
  • Make: Optional but recommended
  • OS: Windows 7+, Linux, or macOS

Installation & Compilation

Using Makefile (Recommended):

# Build the program
make

# Build with debugging symbols
make debug

# Build optimized version
make release

# Clean build artifacts
make clean

# Build and run
make run

# Show all available commands
make help

Manual Compilation:

Linux/macOS:

gcc -o testdata-manager main.c unit_tests.c e2e_tests.c -Wall -Wextra

Windows (MinGW):

gcc -o testdata-manager.exe main.c unit_tests.c e2e_tests.c -Wall -Wextra

Debug build:

gcc -g -o testdata-manager-debug main.c unit_tests.c e2e_tests.c -Wall -Wextra

Running the Application

Linux/macOS:

./testdata-manager

Windows:

testdata-manager.exe

Memory Debugging with Valgrind

Install Valgrind (Ubuntu/Debian):

sudo apt-get install valgrind

Run with memory checking:

# Basic memory check
valgrind --leak-check=full ./testdata-manager

# Detailed analysis
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./testdata-manager

# Memory error detection
valgrind --tool=memcheck --track-origins=yes ./testdata-manager

Usage Guide

First Run

  1. Database Selection: Choose an existing CSV file or create a new database
  2. CSV Format: Files must have the header: TestID,SystemName,TestType,TestResult,Active

Main Operations

1. List Records

  • View all active records with pagination
  • Automatic pagination for large datasets

2. Add New Record

  • System Name: 3+ characters, alphanumeric with ()[]-._ allowed
  • Test Type: 3+ characters, alphanumeric only
  • Test Result: Pending, Failed, Passed, Success

3. Search Records

  • Search across TestID, SystemName, TestType, TestResult
  • Minimum 3 characters required
  • Case-insensitive search

4. Update Records

  • Modify SystemName, TestType, or TestResult
  • Preview changes before saving
  • Rollback support

5. Data Recovery

  • View soft-deleted records
  • Recover or permanently delete records

Sample Data Files

The project includes test files in test_files/ directory:

  • valid_basic.csv - Basic valid records
  • realistic_test_data.csv - Production-like data
  • memory_test_10k.csv - Performance testing data

Testing

Unit Tests

# Run built-in unit tests
./testdata-manager
# Select option 7 > 1 (Unit tests)

End-to-End Tests

# Run E2E tests
./testdata-manager
# Select option 7 > 2 (End-to-end tests)

Memory Testing

# Test with sample data
valgrind --leak-check=full ./testdata-manager < test_input.txt

# Load large dataset for stress testing
cp test_files/memory_test_10k.csv current_test.csv
valgrind ./testdata-manager

CSV File Format

TestID,SystemName,TestType,TestResult,Active
1,Web Application,UnitTest,Passed,1
2,API Gateway,IntegrationTest,Failed,1
3,Database Layer,SystemTest,Pending,0

Field Specifications:

  • TestID: Positive integer (auto-generated)
  • SystemName: 3+ chars, alphanumeric with special chars allowed
  • TestType: 3+ chars, alphanumeric only
  • TestResult: Failed, Passed, Pending, Success
  • Active: 1 (active) or 0 (deleted)

Troubleshooting

Common Issues

Memory allocation failed:

  • Check available system memory
  • Reduce dataset size if necessary

Invalid CSV header:

  • Ensure exact header format: TestID,SystemName,TestType,TestResult,Active
  • No extra spaces or different casing

Compilation errors on Windows:

  • Install MinGW-w64
  • Use Windows-compatible paths

Debug Mode

Compile with debug flags for detailed logging:

gcc -o testdata-manager main.c -g -DDEBUG -fsanitize=address

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Test with Valgrind (Linux) or similar tools
  4. Submit a pull request

License

This project is open source. See LICENSE file for details.

About

This project is part of the Programming Fundamental course @ CECS KMITL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •