You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `Test` Gh workflow is enhanced by also running the whole test suite
with the `LEAK_CHECK` environment variable.
While testing this functionality, it became apparent that we had memory
leaks on `CBLCollection`, `CBLScope` & `CBLQueryIndex` objects.
The functions `retain` and `wrap` were not clear enough on what they
did, especially with the doc comments that were inverted. So the changes
are:
1. Rename `retain` to `reference`
2. Rename `wrap` to `take_ownership`
3. Fix the doc comments on all functions
4. Fix the cases where retain and wrap were misused for `CBLCollection`,
`CBLScope` & `CBLQueryIndex`
5. Implement `Drop` for `QueryIndex`
The tests are now passing with the `LEAK_CHECK` environment variable.
Additional changes:
- The README is improved to document how to test
- The README is improved to make editions (`community` & `enterprise`)
more understandable
- The file `src/main.rs` is deleted as this is a library
Copy file name to clipboardExpand all lines: README.md
+38-11Lines changed: 38 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,22 +20,25 @@ Installation instructions are [here][BINDGEN_INSTALL].
20
20
21
21
### 2. Build!
22
22
23
-
You can use Couchbase Lite C community or entreprise editions:
23
+
There two different editions of Couchbase Lite C: community & enterprise.
24
+
You can find the differences [here][CBL_EDITIONS_DIFF].
25
+
26
+
When building or declaring this repository as a dependency, you need to specify the edition through a cargo feature:
24
27
25
28
```shell
26
-
$ cargo build --features=enterprise
29
+
$ cargo build --features=community
27
30
```
28
31
29
32
```shell
30
-
$ cargo build --features=community
33
+
$ cargo build --features=enterprise
31
34
```
32
35
33
36
## Maintaining
34
37
35
38
### Couchbase Lite For C
36
39
37
40
The Couchbase Lite For C shared library and headers ([Git repo][CBL_C]) are already embedded in this repo.
38
-
They are present in the directory `libcblite`.
41
+
They are present in two directories, one for each edition: `libcblite_community` & `libcblite_enterprise`.
39
42
40
43
### Upgrade Couchbase Lite C
41
44
@@ -54,24 +57,46 @@ $ brew install wget
54
57
$ brew install bash
55
58
```
56
59
57
-
After that, fix the compilation & tests and you can create a pull request.
60
+
If the script was successful:
61
+
- Change the link `CBL_API_REFERENCE` in this README
62
+
- Change the version in the test `couchbase_lite_c_version_test`
63
+
- Update the version in `Cargo.toml`
64
+
- Fix the compilation in both editions
65
+
- Fix the tests in both editions
66
+
- Create pull request
58
67
59
68
New C features should also be added to the Rust API at some point.
60
69
61
70
### Test
62
71
63
-
**The unit tests must be run single-threaded.** This is because each test case checks for leaks by
64
-
counting the number of extant Couchbase Lite objects before and after it runs, and failing if the
65
-
number increases. That works only if a single test runs at a time.
72
+
Tests can be found in the `tests` subdirectory.
73
+
Test are run in the GitHub wrokflow `Test`. You can find the commands used there.
74
+
75
+
There are three variations:
76
+
77
+
### Nominal run
66
78
67
79
```shell
68
-
$ LEAK_CHECK=y cargo test -- --test-threads 1
80
+
$ cargo test --features=enterprise
69
81
```
70
82
71
-
### Sanitizer
83
+
### Run with Couchbase Lite C leak check
84
+
85
+
Couchbase Lite C allows checking if instances of their objects are still alive through the functions `CBL_InstanceCount` & `CBL_DumpInstances`.
86
+
If the `LEAK_CHECK` environment variable is set, we check that the number of instances at the end of each test is 0.
87
+
88
+
If this step fails in one of your pull requests, you should look into the `take_ownership`/`reference` logic on CBL pointers in the constructor of the Rust structs:
89
+
-`take_ownership` takes ownership of the pointer, it will not increase the ref count of the `ref` CBL pointer so releasing it (in a `drop` for example) will free the pointer
90
+
-`reference` just references the pointer, it will increase the ref count of CBL pointers so releasing it will not free the pointer
72
91
73
92
```shell
74
-
$ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test
93
+
$ LEAK_CHECK=y cargo test --features=enterprise -- --test-threads 1
94
+
```
95
+
96
+
### Run with address sanitizer
97
+
98
+
```shell
99
+
$ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nightly test --features=enterprise
0 commit comments