Skip to content

Commit 042ef2c

Browse files
authored
Merge pull request #1 from zombocoder/feature/refacroing
Refactor constants for clarity and maintainability
2 parents 42464bc + 2b8968b commit 042ef2c

15 files changed

Lines changed: 813 additions & 128 deletions

File tree

.github/workflows/freebsd-build.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
release: '14.3'
2020
usesh: true
2121
prepare: |
22-
pkg install -y llvm
22+
pkg install -y llvm kyua
2323
2424
run: |
2525
# Print FreeBSD version
@@ -56,4 +56,49 @@ jobs:
5656
# Check module information
5757
file bfcfs.ko
5858
59-
echo "All checks passed!"
59+
echo "Build successful! Now running tests..."
60+
61+
# Verify test fixture exists
62+
if [ ! -f tests/fixtures/test.bfc ]; then
63+
echo "Warning: Test fixture tests/fixtures/test.bfc not found, skipping tests"
64+
echo "All checks passed (build only)!"
65+
exit 0
66+
fi
67+
68+
echo "Test container found, proceeding with tests..."
69+
70+
# Load the kernel module
71+
echo "Loading BFCFS kernel module..."
72+
kldload ./bfcfs.ko || {
73+
echo "ERROR: Failed to load kernel module"
74+
kldstat
75+
dmesg | tail -20
76+
exit 1
77+
}
78+
79+
# Verify module is loaded
80+
kldstat | grep bfcfs || {
81+
echo "ERROR: Module not loaded"
82+
exit 1
83+
}
84+
85+
# Run the tests
86+
echo "Running BFCFS tests..."
87+
cd tests
88+
kyua test || {
89+
echo "Tests failed, showing report:"
90+
kyua report --verbose
91+
cd ..
92+
kldunload bfcfs || true
93+
exit 1
94+
}
95+
96+
# Show test report
97+
echo "Test results:"
98+
kyua report
99+
100+
# Unload module
101+
cd ..
102+
kldunload bfcfs
103+
104+
echo "All checks and tests passed!"

README.md

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Low-level I/O routines (pread, object reading, CRC verification)
130130
bfcfs-freebsd/
131131
├── .github/
132132
│ └── workflows/
133-
│ └── freebsd-build.yml # GitHub Actions CI
133+
│ └── freebsd-build.yml # GitHub Actions CI with tests
134134
├── .gitignore # Git ignore rules
135135
├── LICENSE # BSD 3-Clause License
136136
├── Makefile # Build configuration
@@ -139,7 +139,16 @@ bfcfs-freebsd/
139139
├── bfcfs_vfs.c # VFS operations
140140
├── bfcfs_vnops.c # Vnode operations
141141
├── bfc_format.c # BFC format parsing
142-
└── bfc_io.c # I/O routines
142+
├── bfc_io.c # I/O routines
143+
└── tests/ # ATF test suite
144+
├── Kyuafile # Test configuration
145+
├── h_funcs.subr # Test helper functions
146+
├── mount_test # Mount/unmount tests
147+
├── read_test # Read operation tests
148+
├── readdir_test # Directory listing tests
149+
├── symlink_test # Symlink tests
150+
└── fixtures/ # Test BFC containers
151+
└── README.md # Fixture documentation
143152
```
144153

145154
## Debugging
@@ -218,14 +227,36 @@ doas kldload ./bfcfs.ko
218227

219228
### Testing:
220229

230+
The module includes an ATF-based test suite using Kyua:
231+
232+
```sh
233+
# Install test dependencies
234+
doas pkg install kyua
235+
236+
# Load the module
237+
doas kldload ./bfcfs.ko
238+
239+
# Run the test suite
240+
cd tests
241+
doas kyua test
242+
243+
# View test results
244+
kyua report
245+
246+
# Detailed report
247+
kyua report --verbose
248+
```
249+
250+
#### Manual Testing:
251+
221252
```sh
222253
# Create a test mount point
223254
doas mkdir -p /mnt/bfc
224255

225256
# Mount test container
226257
doas mount -t bfcfs -o ro /path/to/test.bfc /mnt/bfc
227258

228-
# Run tests
259+
# Run manual tests
229260
ls -la /mnt/bfc
230261
cat /mnt/bfc/somefile.txt
231262
find /mnt/bfc -type f
@@ -234,6 +265,21 @@ find /mnt/bfc -type f
234265
doas umount /mnt/bfc
235266
```
236267

268+
### Test Suite Structure:
269+
270+
```
271+
tests/
272+
├── Kyuafile # Test configuration
273+
├── h_funcs.subr # Helper functions
274+
├── mount_test # Mount/unmount tests
275+
├── read_test # Read operations tests
276+
├── readdir_test # Directory listing tests
277+
├── symlink_test # Symlink support tests
278+
└── fixtures/
279+
├── README.md # Fixture documentation
280+
└── test.bfc # Test BFC container
281+
```
282+
237283
## License
238284

239285
BSD 3-Clause License - See [LICENSE](LICENSE) file for details
@@ -315,12 +361,12 @@ doas mount -t bfcfs -o ro /var/containers/website.bfc /var/www/html
315361

316362
| Feature | BFCFS | SquashFS | ISO9660 | FUSE |
317363
| -------------- | ----- | -------- | ------- | ------ |
318-
| Read-only | | | | |
319-
| Kernel module | | | | |
320-
| Compression | 🚧 | | | Varies |
321-
| Encryption | 🚧 | | | Varies |
322-
| CRC integrity | | | | Varies |
323-
| Cross-platform | | | | |
364+
| Read-only | [x] | [x] | [x] | [-] |
365+
| Kernel module | [x] | [x] | [x] | [-] |
366+
| Compression | [ ] | [x] | [-] | Varies |
367+
| Encryption | [ ] | [-] | [-] | Varies |
368+
| CRC integrity | [x] | [x] | [-] | Varies |
369+
| Cross-platform | [x] | [x] | [x] | [x] |
324370
| Performance | High | High | High | Medium |
325371

326372
## Project Status
@@ -329,20 +375,20 @@ doas mount -t bfcfs -o ro /var/containers/website.bfc /var/www/html
329375

330376
### Implemented Features
331377

332-
- Mount/unmount operations
333-
- Directory listing and navigation
334-
- File reading (uncompressed)
335-
- Symlink support
336-
- CRC32C verification
337-
- Hardware-accelerated checksums
378+
- [x] Mount/unmount operations
379+
- [x] Directory listing and navigation
380+
- [x] File reading (uncompressed)
381+
- [x] Symlink support
382+
- [x] CRC32C verification
383+
- [x] Hardware-accelerated checksums
338384

339385
### Planned Features (Roadmap)
340386

341-
- 🚧 ZSTD decompression support
342-
- 🚧 ChaCha20-Poly1305 decryption support
343-
- 🚧 Extended attributes
344-
- 🚧 Advanced mount options
345-
- 🚧 Performance optimizations
387+
- [ ] ZSTD decompression support
388+
- [ ] ChaCha20-Poly1305 decryption support
389+
- [ ] Extended attributes
390+
- [ ] Advanced mount options
391+
- [ ] Performance optimizations
346392

347393
## Contributing
348394

0 commit comments

Comments
 (0)