This directory contains a comprehensive test framework for the OpenDAL C binding, modeled after the Python and JavaScript binding test suites.
The test framework follows the standard OpenDAL testing pattern:
# Test with memory service (default) OPENDAL_TEST=memory make behavior_test # Test with filesystem service OPENDAL_TEST=fs OPENDAL_FS_ROOT=/tmp/test make behavior_test # Test with S3 service OPENDAL_TEST=s3 OPENDAL_S3_BUCKET=test-bucket OPENDAL_S3_REGION=us-east-1 make behavior_test
The test framework implements the core requirements:
OPENDAL_TEST
as the scheme to testOPENDAL_{scheme}_{key}={value}
environment variables to construct the operatorOPENDAL_DISABLE_RANDOM_ROOT=true
)The test framework provides:
test_framework.h/cpp
: Core framework with assertion macros, configuration management, and test runnertest_suites_basic.cpp
: Basic CRUD operations (check, write, read, exists, stat, delete, create_dir)test_suites_list.cpp
: Directory listing and traversal operationstest_suites_reader_writer.cpp
: Streaming read/write operations with seek functionalitytest_runner.cpp
: Main executable with command-line interfaceEach test case specifies:
# Build the test runner make all # Or use the existing build system cd .. make # This should build the C binding cd tests make
# Run all tests (default: memory service) ./opendal_test_runner # List available test suites ./opendal_test_runner --list-suites # Run specific test suite ./opendal_test_runner --suite "Basic Operations" # Run specific test case ./opendal_test_runner --test "Basic Operations::write_read" # Get help ./opendal_test_runner --help
Configure the service via environment variables:
# Test with memory service (default) OPENDAL_TEST=memory ./opendal_test_runner # Test with filesystem service OPENDAL_TEST=fs OPENDAL_FS_ROOT=/tmp/opendal_test ./opendal_test_runner # Test with S3 service OPENDAL_TEST=s3 \ OPENDAL_S3_BUCKET=my-bucket \ OPENDAL_S3_REGION=us-west-2 \ OPENDAL_S3_ACCESS_KEY_ID=your-key \ OPENDAL_S3_SECRET_ACCESS_KEY=your-secret \ ./opendal_test_runner # Disable random root generation OPENDAL_DISABLE_RANDOM_ROOT=true ./opendal_test_runner
make test # Run all tests with memory service make test-memory # Run tests with memory service make test-fs # Run tests with filesystem service make list-suites # List all available test suites make help # Show make help
The test framework follows the same configuration pattern as Python/JavaScript bindings:
OPENDAL_TEST
: Service to test (memory, fs, s3, gcs, azblob, etc.)OPENDAL_DISABLE_RANDOM_ROOT
: Set to ‘true’ to disable random root generationOPENDAL_<SERVICE>_<CONFIG>
: Service-specific configuration keysFilesystem:
OPENDAL_TEST=fs OPENDAL_FS_ROOT=/path/to/test/directory
S3:
OPENDAL_TEST=s3 OPENDAL_S3_BUCKET=test-bucket OPENDAL_S3_REGION=us-east-1 OPENDAL_S3_ACCESS_KEY_ID=your-access-key OPENDAL_S3_SECRET_ACCESS_KEY=your-secret-key
Azure Blob:
OPENDAL_TEST=azblob OPENDAL_AZBLOB_CONTAINER=test-container OPENDAL_AZBLOB_ACCOUNT_NAME=your-account OPENDAL_AZBLOB_ACCOUNT_KEY=your-key
Tests fundamental CRUD operations:
Tests directory listing and traversal:
Tests streaming I/O operations:
The framework provides comprehensive assertion macros:
OPENDAL_ASSERT(condition, message) // General condition check OPENDAL_ASSERT_EQ(expected, actual, message) // Equality check OPENDAL_ASSERT_STR_EQ(expected, actual, message) // String equality OPENDAL_ASSERT_NULL(ptr, message) // Null pointer check OPENDAL_ASSERT_NOT_NULL(ptr, message) // Non-null pointer check OPENDAL_ASSERT_NO_ERROR(error, message) // OpenDAL error check