summaryrefslogtreecommitdiff
path: root/t/t0080-vcs-svn.sh
diff options
context:
space:
mode:
authorDavid Barr <david.barr@cordelta.com>2010-08-09 22:11:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-08-15 02:35:37 (GMT)
commit4709455db3891f6cad9a96a574296b4926f70cbe (patch)
treef97a6a3f25259a67427e48bc85433173006a4e6b /t/t0080-vcs-svn.sh
parent3f527372d9ec6d7b6890773e41c4b3542d7ad451 (diff)
downloadgit-4709455db3891f6cad9a96a574296b4926f70cbe.zip
git-4709455db3891f6cad9a96a574296b4926f70cbe.tar.gz
git-4709455db3891f6cad9a96a574296b4926f70cbe.tar.bz2
Add memory pool library
Add a memory pool library implemented using C macros. The obj_pool_gen() macro creates a type-specific memory pool. The memory pool library is distinguished from the existing specialized allocators in alloc.c by using a contiguous block for all allocations. This means that on one hand, long-lived pointers have to be written as offsets, since the base address changes as the pool grows, but on the other hand, the entire pool can be easily written to the file system. This could allow the memory pool to persist between runs of an application. For the svn importer, such a facility is useful because each svn revision can copy trees and files from any previous revision. The relevant information for all revisions has to persist somehow to support incremental runs. [rr: minor cleanups] [jn: added tests; removed file system backing for now] Signed-off-by: David Barr <david.barr@cordelta.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0080-vcs-svn.sh')
-rwxr-xr-xt/t0080-vcs-svn.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/t/t0080-vcs-svn.sh b/t/t0080-vcs-svn.sh
new file mode 100755
index 0000000..3f29496
--- /dev/null
+++ b/t/t0080-vcs-svn.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+test_description='check infrastructure for svn importer'
+
+. ./test-lib.sh
+uint32_max=4294967295
+
+test_expect_success 'obj pool: store data' '
+ cat <<-\EOF >expected &&
+ 0
+ 1
+ EOF
+
+ test-obj-pool <<-\EOF >actual &&
+ alloc one 16
+ set one 13
+ test one 13
+ reset one
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'obj pool: NULL is offset ~0' '
+ echo "$uint32_max" >expected &&
+ echo null one | test-obj-pool >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'obj pool: out-of-bounds access' '
+ cat <<-EOF >expected &&
+ 0
+ 0
+ $uint32_max
+ $uint32_max
+ 16
+ 20
+ $uint32_max
+ EOF
+
+ test-obj-pool <<-\EOF >actual &&
+ alloc one 16
+ alloc two 16
+ offset one 20
+ offset two 20
+ alloc one 5
+ offset one 20
+ free one 1
+ offset one 20
+ reset one
+ reset two
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'obj pool: high-water mark' '
+ cat <<-\EOF >expected &&
+ 0
+ 0
+ 10
+ 20
+ 20
+ 20
+ EOF
+
+ test-obj-pool <<-\EOF >actual &&
+ alloc one 10
+ committed one
+ alloc one 10
+ commit one
+ committed one
+ alloc one 10
+ free one 20
+ committed one
+ reset one
+ EOF
+ test_cmp expected actual
+'
+
+test_done