From fe9ee6370d1f5be9d6fa1fc2dd8a17baf0cecb02 Mon Sep 17 00:00:00 2001 From: Konstantin Kushnir Date: Thu, 30 May 2024 07:07:02 +0300 Subject: [PATCH] Add feature to build without Tcl commands (#10) --- .github/workflows/linux-build-c.yml | 60 ++++++ .github/workflows/linux-build.yml | 2 - ChangeLog | 1 + TODO.txt | 1 - configure | 31 +++ configure.in | 19 ++ generic/cookfs.c | 22 +-- generic/cookfs.h | 1 + generic/vfs.c | 6 + generic/vfs.h | 4 + generic/vfsCmd.c | 121 ++++++++---- generic/vfsVfs.c | 2 + pkgconfig.tcl.in | 2 + tests/all.tcl | 15 +- tests/compression.test | 16 +- tests/cookfswriter.test | 12 +- tests/dedup.test | 16 +- tests/fsindex.test | 68 +++---- tests/pages.test | 144 +++++++------- tests/pagesAsync.test | 26 +-- tests/pkgconfig.test | 1 + tests/readerchannel.test | 64 +++--- tests/vfs.test | 290 ++++++++++++++-------------- tests/vfsCache.test | 2 +- tests/writer.test | 80 ++++---- 25 files changed, 594 insertions(+), 412 deletions(-) create mode 100644 .github/workflows/linux-build-c.yml diff --git a/.github/workflows/linux-build-c.yml b/.github/workflows/linux-build-c.yml new file mode 100644 index 0000000..498fc6d --- /dev/null +++ b/.github/workflows/linux-build-c.yml @@ -0,0 +1,60 @@ +name: Linux (without Tcl commands) +on: [push] +permissions: + contents: read +defaults: + run: + shell: bash +jobs: + build: + runs-on: ubuntu-24.04 + timeout-minutes: 5 + strategy: + matrix: + compiler: ["gcc", "clang"] + name: build (${{ matrix.compiler }}) + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Setup Environment (compiler=${{ matrix.compiler }}) + run: | + sudo apt-get install tcl8.6-dev + mkdir "$HOME/install dir" + echo "CFGOPT_COMMON=--with-tcl=/usr/lib/tcl8.6" >> $GITHUB_ENV + echo "CC=$COMPILER" >> $GITHUB_ENV + env: + COMPILER: ${{ matrix.compiler }} + OPTS: ${{ matrix.compiler }} + - name: Configure + run: | + ./configure $CFGOPT_COMMON --disable-tcl-commands "--prefix=$HOME/install dir" "--exec-prefix=$HOME/install dir" || { + cat config.log + echo "::error::Failure during Configure" + exit 1 + } + - name: Build + run: | + make -j || { + echo "::error::Failure during Build" + exit 1 + } + - name: Run Tests + run: | + make test || { + echo "::error::Failure during Test" + exit 1 + } + - name: Test-Drive Installation + run: | + make install || { + echo "::error::Failure during Install" + exit 1 + } + - name: Create Distribution Package + run: | + make dist || { + echo "::error::Failure during Distribute" + exit 1 + } diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index 32acebe..9f71e84 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -69,8 +69,6 @@ jobs: echo "::error::Failure during Test" exit 1 } - env: - ERROR_ON_FAILURES: 1 - name: Test-Drive Installation run: | make install || { diff --git a/ChangeLog b/ChangeLog index 5d5935b..c10d9b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2024-05-30 Konstantin Kushnir * Fix multiple memory leaks + * Add feature to build without Tcl commands 2024-05-29 Konstantin Kushnir * Fix a regression when register volume and unregister with vfs::unmount diff --git a/TODO.txt b/TODO.txt index ed78240..5d760a3 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,2 +1 @@ * Add support for Tcl9 -* Add ability to disable Tcl commands for pages/index. This should reduce binary size. diff --git a/configure b/configure index 20fa538..5967539 100755 --- a/configure +++ b/configure @@ -657,6 +657,7 @@ MAKE_LIB EGREP GREP COOKFS_PKGCONFIG_USECPKGCONFIG +COOKFS_PKGCONFIG_USETCLCMDS COOKFS_PKGCONFIG_USECWRITER COOKFS_PKGCONFIG_USECVFS COOKFS_PKGCONFIG_FEATURE_METADATA @@ -795,6 +796,7 @@ enable_c_writerchannel enable_c_pkgconfig enable_c_vfs enable_c_writer +enable_tcl_commands ' ac_precious_vars='build_alias host_alias @@ -1442,6 +1444,7 @@ Optional Features: --disable-c-pkgconfig Use pkgconfig written in C. Defaults to true --disable-c-vfs Use VFS support written in C. Defaults to true --disable-c-writer Use writer handler written in C. Defaults to true + --disable-tcl-commands Enable Tcl commands for objects. Defaults to true Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -8661,6 +8664,15 @@ else $as_nop USECWRITER=yes fi +# Check whether --enable-tcl-commands was given. +if test ${enable_tcl_commands+y} +then : + enableval=$enable_tcl_commands; USETCLCMDS=${enableval} +else $as_nop + USETCLCMDS=yes +fi + + if test ${INTERNALDEBUG} = yes; then printf "%s\n" "#define COOKFS_INTERNAL_DEBUG 1" >>confdefs.h @@ -9177,6 +9189,23 @@ else COOKFS_PKGCONFIG_USECVFS=0 fi +if test ${USETCLCMDS} = no \ + && test ${USECWRITER} = yes \ + && test ${USECWRITERCHAN} = yes \ + && test ${USECVFS} = yes \ + && test ${USECPAGES} = yes \ + && test ${USECFSINDEX} = yes \ + && test ${USECREADERCHAN} = yes +then + COOKFS_PKGCONFIG_USETCLCMDS=0 +else + printf "%s\n" "#define COOKFS_USETCLCMDS 1" >>confdefs.h + + COOKFS_PKGCONFIG_USETCLCMDS=1 +fi + + + @@ -9212,6 +9241,8 @@ if test ${USECPKGCONFIG} = yes; then printf "%s\n" "#define COOKFS_PKGCONFIG_USECWRITER $COOKFS_PKGCONFIG_USECWRITER" >>confdefs.h + printf "%s\n" "#define COOKFS_PKGCONFIG_USETCLCMDS $COOKFS_PKGCONFIG_USETCLCMDS" >>confdefs.h + printf "%s\n" "#define COOKFS_USECPKGCONFIG 1" >>confdefs.h diff --git a/configure.in b/configure.in index 1505439..5a71c81 100644 --- a/configure.in +++ b/configure.in @@ -124,6 +124,8 @@ AC_ARG_ENABLE(c-writerchannel, [ --disable-c-writerchannel Use writer handler w AC_ARG_ENABLE(c-pkgconfig, [ --disable-c-pkgconfig Use pkgconfig written in C. Defaults to true], USECPKGCONFIG=${enableval}, USECPKGCONFIG=yes) AC_ARG_ENABLE(c-vfs, [ --disable-c-vfs Use VFS support written in C. Defaults to true], USECVFS=${enableval}, USECVFS=yes) AC_ARG_ENABLE(c-writer, [ --disable-c-writer Use writer handler written in C. Defaults to true], USECWRITER=${enableval}, USECWRITER=yes) +AC_ARG_ENABLE(tcl-commands, [ --disable-tcl-commands Enable Tcl commands for objects. Defaults to true], USETCLCMDS=${enableval}, USETCLCMDS=yes) + if test ${INTERNALDEBUG} = yes; then AC_DEFINE(COOKFS_INTERNAL_DEBUG) @@ -247,6 +249,21 @@ else COOKFS_PKGCONFIG_USECVFS=0 fi +if test ${USETCLCMDS} = no \ + && test ${USECWRITER} = yes \ + && test ${USECWRITERCHAN} = yes \ + && test ${USECVFS} = yes \ + && test ${USECPAGES} = yes \ + && test ${USECFSINDEX} = yes \ + && test ${USECREADERCHAN} = yes +then + COOKFS_PKGCONFIG_USETCLCMDS=0 +else + AC_DEFINE(COOKFS_USETCLCMDS) + COOKFS_PKGCONFIG_USETCLCMDS=1 +fi + + AC_SUBST(COOKFS_PKGCONFIG_FEATURE_ASIDE) AC_SUBST(COOKFS_PKGCONFIG_USECPAGES) AC_SUBST(COOKFS_PKGCONFIG_USECREADERCHAN) @@ -257,6 +274,7 @@ AC_SUBST(COOKFS_PKGCONFIG_USECFSINDEX) AC_SUBST(COOKFS_PKGCONFIG_FEATURE_METADATA) AC_SUBST(COOKFS_PKGCONFIG_USECVFS) AC_SUBST(COOKFS_PKGCONFIG_USECWRITER) +AC_SUBST(COOKFS_PKGCONFIG_USETCLCMDS) if test ${USECPKGCONFIG} = yes; then COOKFS_PKGCONFIG_USECPKGCONFIG=1 @@ -271,6 +289,7 @@ if test ${USECPKGCONFIG} = yes; then AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_FEATURE_METADATA, $COOKFS_PKGCONFIG_FEATURE_METADATA) AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USECVFS, $COOKFS_PKGCONFIG_USECVFS) AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USECWRITER, $COOKFS_PKGCONFIG_USECWRITER) + AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USETCLCMDS, $COOKFS_PKGCONFIG_USETCLCMDS) AC_DEFINE(COOKFS_USECPKGCONFIG) else diff --git a/generic/cookfs.c b/generic/cookfs.c index 9512f4d..2c7167b 100644 --- a/generic/cookfs.c +++ b/generic/cookfs.c @@ -28,41 +28,39 @@ DLLEXPORT int Cookfs_Init(Tcl_Interp *interp) // cppcheck-suppress unusedFunction { - char buf[256]; + if (Tcl_InitStubs(interp, "8.5", 0) == NULL) { return TCL_ERROR; } - strcpy(buf, "namespace eval ::cookfs {} ; namespace eval ::cookfs::c {}"); - if (Tcl_EvalEx(interp, buf, -1, TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL) != TCL_OK) { - return TCL_ERROR; - } + Tcl_CreateNamespace(interp, "::cookfs", NULL, NULL); + Tcl_CreateNamespace(interp, "::cookfs::c", NULL, NULL); -#ifdef COOKFS_USECPAGES +#if defined(COOKFS_USECPAGES) && defined(COOKFS_USETCLCMDS) if (Cookfs_InitPagesCmd(interp) != TCL_OK) { return TCL_ERROR; } #endif -#ifdef COOKFS_USECFSINDEX +#if defined(COOKFS_USECFSINDEX) && defined(COOKFS_USETCLCMDS) if (Cookfs_InitFsindexCmd(interp) != TCL_OK) { return TCL_ERROR; } #endif -#ifdef COOKFS_USECREADERCHAN +#if defined(COOKFS_USECREADERCHAN) && defined(COOKFS_USETCLCMDS) if (Cookfs_InitReaderchannelCmd(interp) != TCL_OK) { return TCL_ERROR; } #endif -#ifdef COOKFS_USECWRITER +#if defined(COOKFS_USECWRITER) && defined(COOKFS_USETCLCMDS) if (Cookfs_InitWriterCmd(interp) != TCL_OK) { return TCL_ERROR; } #endif -#ifdef COOKFS_USECWRITERCHAN +#if defined(COOKFS_USECWRITERCHAN) && defined(COOKFS_USETCLCMDS) if (Cookfs_InitWriterchannelCmd(interp) != TCL_OK) { return TCL_ERROR; } @@ -76,13 +74,13 @@ Cookfs_Init(Tcl_Interp *interp) // cppcheck-suppress unusedFunction return TCL_ERROR; } -#ifdef COOKFS_USECVFS +#if defined(COOKFS_USECVFS) if (Cookfs_InitVfsMountCmd(interp) != TCL_OK) { return TCL_ERROR; } #endif -#ifdef COOKFS_USECPKGCONFIG +#if defined(COOKFS_USECPKGCONFIG) Tcl_RegisterConfig(interp, PACKAGE_NAME, cookfs_pkgconfig, "iso8859-1"); if (Tcl_PkgProvide(interp, PACKAGE_NAME "::pkgconfig", PACKAGE_VERSION) != TCL_OK) { diff --git a/generic/cookfs.h b/generic/cookfs.h index f690f6e..a0b2ad2 100644 --- a/generic/cookfs.h +++ b/generic/cookfs.h @@ -83,6 +83,7 @@ static Tcl_Config const cookfs_pkgconfig[] = { {"feature-bzip2", STRINGIFY(COOKFS_PKGCONFIG_USEBZ2)}, {"feature-xz", STRINGIFY(COOKFS_PKGCONFIG_USEXZ)}, {"feature-metadata", STRINGIFY(COOKFS_PKGCONFIG_FEATURE_METADATA)}, + {"tcl-commands", STRINGIFY(COOKFS_PKGCONFIG_USETCLCMDS)}, {NULL, NULL} }; #endif /* COOKFS_USECPKGCONFIG */ diff --git a/generic/vfs.c b/generic/vfs.c index d374a42..897902d 100644 --- a/generic/vfs.c +++ b/generic/vfs.c @@ -47,7 +47,9 @@ Cookfs_Vfs *Cookfs_VfsInit(Tcl_Interp* interp, Tcl_Obj* mountPoint, vfs->commandToken = NULL; vfs->interp = interp; vfs->isDead = 0; +#ifdef COOKFS_USETCLCMDS vfs->isRegistered = 0; +#endif vfs->isVolume = isVolume; vfs->isCurrentDirTime = isCurrentDirTime; vfs->isReadonly = isReadonly; @@ -174,6 +176,8 @@ int Cookfs_VfsFini(Tcl_Interp *interp, Cookfs_Vfs *vfs, return TCL_OK; } +#ifdef COOKFS_USETCLCMDS + void Cookfs_VfsUnregisterInTclvfs(Cookfs_Vfs *vfs) { if (!vfs->isRegistered) { @@ -268,6 +272,8 @@ int Cookfs_VfsRegisterInTclvfs(Cookfs_Vfs *vfs) { return ret; } +#endif + int Cookfs_VfsIsReadonly(Cookfs_Vfs *vfs) { return vfs->isReadonly; } diff --git a/generic/vfs.h b/generic/vfs.h index 3cbfd21..f2672e4 100644 --- a/generic/vfs.h +++ b/generic/vfs.h @@ -14,7 +14,9 @@ typedef struct Cookfs_Vfs { Tcl_Command commandToken; int isDead; +#ifdef COOKFS_USETCLCMDS int isRegistered; +#endif int isCurrentDirTime; int isVolume; @@ -38,7 +40,9 @@ int Cookfs_VfsFini(Tcl_Interp *interp, Cookfs_Vfs *vfs, int Cookfs_VfsIsReadonly(Cookfs_Vfs *vfs); void Cookfs_VfsSetReadonly(Cookfs_Vfs *vfs, int status); +#ifdef COOKFS_USETCLCMDS void Cookfs_VfsUnregisterInTclvfs(Cookfs_Vfs *vfs); int Cookfs_VfsRegisterInTclvfs(Cookfs_Vfs *vfs); +#endif #endif /* COOKFS_VFS_H */ diff --git a/generic/vfsCmd.c b/generic/vfsCmd.c index 856cc84..4d56030 100644 --- a/generic/vfsCmd.c +++ b/generic/vfsCmd.c @@ -73,9 +73,13 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, CookfsLog(printf("CookfsMountCmd: ENTER")); +#ifdef COOKFS_USETCLCMDS + Tcl_Obj *pagesobject = NULL; + Tcl_Obj *fsindexobject = NULL; int noregister = 0; - int nocommand = 0; Tcl_Obj *bootstrap = NULL; +#endif + int nocommand = 0; Tcl_Obj *compression = NULL; int alwayscompress = 0; Tcl_Obj *compresscommand = NULL; @@ -84,8 +88,6 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, int asyncdecompressqueuesize = 2; Tcl_Obj *decompresscommand = NULL; Tcl_WideInt endoffset = -1; - Tcl_Obj *pagesobject = NULL; - Tcl_Obj *fsindexobject = NULL; Tcl_Obj *setmetadata = NULL; int readonly = 0; int writetomemory = 0; @@ -101,24 +103,28 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, Tcl_Obj *local = NULL; static const char *const options[] = { - "-noregister", "-nocommand", "-bootstrap", "-compression", - "-alwayscompress", "-compresscommand", "-asynccompresscommand", - "-asyncdecompresscommand", "-asyncdecompressqueuesize", - "-decompresscommand", "-endoffset", "-pagesobject", - "-fsindexobject", "-setmetadata", "-readonly", "-writetomemory", - "-pagesize", "-pagecachesize", "-volume", "-smallfilesize", - "-smallfilebuffer", "-nodirectorymtime", "-pagehash", +#ifdef COOKFS_USETCLCMDS + "-pagesobject", "-fsindexobject", "-noregister", "-bootstrap", +#endif + "-nocommand", "-compression", "-alwayscompress", "-compresscommand", + "-asynccompresscommand", "-asyncdecompresscommand", + "-asyncdecompressqueuesize", "-decompresscommand", "-endoffset", + "-setmetadata", "-readonly", "-writetomemory", "-pagesize", + "-pagecachesize", "-volume", "-smallfilesize", "-smallfilebuffer", + "-nodirectorymtime", "-pagehash", NULL }; enum options { - OPT_NOREGISTER = 0, OPT_NOCOMMAND, OPT_BOOTSTRAP, OPT_COMPRESSION, - OPT_ALWAYSCOMPRESS, OPT_COMPRESSCOMMAND, OPT_ASYNCCOMPRESSCOMMAND, - OPT_ASYNCDECOMPRESSCOMMAND, OPT_ASYNCDECOMPRESSQUEUESIZE, - OPT_DECOMPRESSCOMMAND, OPT_ENDOFFSET, OPT_PAGEOBJECT, - OPT_FSINDEXOBJECT, OPT_SETMETADATA, OPT_READONLY, OPT_WRITETOMEMORY, - OPT_PAGESIZE, OPT_PAGECACHESIZE, OPT_VOLUME, OPT_SMALLFILESIZE, - OPT_SMALLFILEBUFFER, OPT_NODIRECTORYMTIME, OPT_PAGEHASH +#ifdef COOKFS_USETCLCMDS + OPT_PAGEOBJECT, OPT_FSINDEXOBJECT, OPT_NOREGISTER, OPT_BOOTSTRAP, +#endif + OPT_NOCOMMAND, OPT_COMPRESSION, OPT_ALWAYSCOMPRESS, OPT_COMPRESSCOMMAND, + OPT_ASYNCCOMPRESSCOMMAND, OPT_ASYNCDECOMPRESSCOMMAND, + OPT_ASYNCDECOMPRESSQUEUESIZE, OPT_DECOMPRESSCOMMAND, OPT_ENDOFFSET, + OPT_SETMETADATA, OPT_READONLY, OPT_WRITETOMEMORY, OPT_PAGESIZE, + OPT_PAGECACHESIZE, OPT_VOLUME, OPT_SMALLFILESIZE, OPT_SMALLFILEBUFFER, + OPT_NODIRECTORYMTIME, OPT_PAGEHASH }; for (int idx = 1; idx < objc; idx++) { @@ -152,7 +158,9 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, } CookfsLog(printf("CookfsMountCmd: arg #%d is a known option", idx)); +#ifdef COOKFS_USETCLCMDS PROCESS_OPT_SWITCH(OPT_NOREGISTER, noregister); +#endif PROCESS_OPT_SWITCH(OPT_NOCOMMAND, nocommand); PROCESS_OPT_SWITCH(OPT_ALWAYSCOMPRESS, alwayscompress); PROCESS_OPT_SWITCH(OPT_READONLY, readonly); @@ -167,14 +175,16 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, return TCL_ERROR; } +#ifdef COOKFS_USETCLCMDS + PROCESS_OPT_OBJ(OPT_PAGEOBJECT, pagesobject); + PROCESS_OPT_OBJ(OPT_FSINDEXOBJECT, fsindexobject); PROCESS_OPT_OBJ(OPT_BOOTSTRAP, bootstrap); +#endif PROCESS_OPT_OBJ(OPT_COMPRESSION, compression); PROCESS_OPT_OBJ(OPT_COMPRESSCOMMAND, compresscommand); PROCESS_OPT_OBJ(OPT_ASYNCCOMPRESSCOMMAND, asynccompresscommand); PROCESS_OPT_OBJ(OPT_ASYNCDECOMPRESSCOMMAND, asyncdecompresscommand); PROCESS_OPT_OBJ(OPT_DECOMPRESSCOMMAND, decompresscommand); - PROCESS_OPT_OBJ(OPT_PAGEOBJECT, pagesobject); - PROCESS_OPT_OBJ(OPT_FSINDEXOBJECT, fsindexobject); PROCESS_OPT_OBJ(OPT_SETMETADATA, setmetadata); PROCESS_OPT_OBJ(OPT_PAGEHASH, pagehash); @@ -313,7 +323,9 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, Tcl_IncrRefCount(localActual); } +#ifdef COOKFS_USETCLCMDS if (pagesobject == NULL) { +#endif int oCompression; if (Cookfs_CompressionFromObj(interp, compression, &oCompression) != TCL_OK) @@ -331,6 +343,7 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, return TCL_ERROR; } +#ifdef COOKFS_USETCLCMDS } else { char *pagesCmd = Tcl_GetString(pagesobject); pages = Cookfs_PagesGetHandle(interp, pagesCmd); @@ -340,6 +353,7 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, return TCL_ERROR; } } +#endif // set whether compression should always be enabled CookfsLog(printf("CookfsMountCmd: set pages always compress: %d", @@ -354,7 +368,9 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, Tcl_DecrRefCount(archiveActual); archiveActual = NULL; +#ifdef COOKFS_USETCLCMDS if (fsindexobject == NULL) { +#endif CookfsLog(printf("CookfsMountCmd: creating the index object")); index = Cookfs_FsindexFromPages(NULL, pages); if (index == NULL) { @@ -362,6 +378,7 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, " index object", -1)); goto error; } +#ifdef COOKFS_USETCLCMDS } else { char *indexCmd = Tcl_GetString(fsindexobject); index = Cookfs_FsindexGetHandle(interp, indexCmd); @@ -371,6 +388,7 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, goto error; } } +#endif const char *pagehashMetadataKey = "cookfs.pagehash"; @@ -405,6 +423,7 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, CookfsLog(printf("CookfsMountCmd: pages don't contain data")); +#ifdef COOKFS_USETCLCMDS if (bootstrap != NULL) { CookfsLog(printf("CookfsMountCmd: bootstrap is specified")); int bootstrapLength; @@ -425,6 +444,7 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, } else { CookfsLog(printf("CookfsMountCmd: bootstrap is not specified")); } +#endif // We will use this object as a flag whether we use the hash value // from the argument or the default value. @@ -526,6 +546,7 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, goto error; } +#ifdef COOKFS_USETCLCMDS if (!noregister) { CookfsLog(printf("CookfsMountCmd: registering the vfs in tclvfs...")); if (Cookfs_VfsRegisterInTclvfs(vfs) != TCL_OK) { @@ -539,22 +560,26 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, CookfsLog(printf("CookfsMountCmd: no need to register the vfs" " in tclvfs")); } +#endif + + Tcl_ResetResult(interp); - char cmd[128]; - sprintf(cmd, "::cookfs::c::vfs::mount%p", (void *)vfs); if (!nocommand) { + + char cmd[128]; + sprintf(cmd, "::cookfs::c::vfs::mount%p", (void *)vfs); + CookfsLog(printf("CookfsMountCmd: creating vfs command handler...")); vfs->commandToken = Tcl_CreateObjCommand(interp, cmd, CookfsMountHandleCmd, vfs, CookfsMountHandleCmdDeleteProc); + + Tcl_SetObjResult(interp, Tcl_NewStringObj(cmd, -1)); + } else { CookfsLog(printf("CookfsMountCmd: no need to create vfs" " command handler")); } - Tcl_ResetResult(interp); - - Tcl_SetObjResult(interp, Tcl_NewStringObj(cmd, -1)); - CookfsLog(printf("CookfsMountCmd: ok [%s]", cmd)); return TCL_OK; @@ -578,12 +603,20 @@ static int CookfsMountCmd(ClientData clientData, Tcl_Interp *interp, } // If no fsindex object was specified and a fsindex object was created // by this procedure, release the fsindex object. +#ifdef COOKFS_USETCLCMDS if (fsindexobject == NULL && index != NULL) { +#else + if (index != NULL) { +#endif Cookfs_FsindexFini(index); } // If no pages object was specified and a pages object was created by // this procedure, release the pages object. +#ifdef COOKFS_USETCLCMDS if (pagesobject == NULL && pages != NULL) { +#else + if (pages != NULL) { +#endif Cookfs_PagesFini(pages); } } @@ -598,6 +631,8 @@ static int CookfsUnmountCmd(ClientData clientData, Tcl_Interp *interp, CookfsLog(printf("CookfsUnmountCmd: ENTER args count:%d", objc)); + Tcl_Obj *arg; +#ifdef COOKFS_USETCLCMDS if (objc < 2 || objc > 3 || (objc == 3 && strcmp(Tcl_GetString(objv[1]), "-unregister") != 0)) { @@ -606,7 +641,6 @@ static int CookfsUnmountCmd(ClientData clientData, Tcl_Interp *interp, return TCL_ERROR; } - Tcl_Obj *arg; if (objc == 2) { // args number is 2, i.e. we were called without -unregister switch // and the first argument is our real argument @@ -616,6 +650,14 @@ static int CookfsUnmountCmd(ClientData clientData, Tcl_Interp *interp, // and the second argument is our real argument arg = objv[2]; } +#else + if (objc != 2) { + CookfsLog(printf("CookfsUnmountCmd: wrong # args")); + Tcl_WrongNumArgs(interp, 1, objv, "fsid|local"); + return TCL_ERROR; + } + arg = objv[1]; +#endif CookfsLog(printf("CookfsUnmountCmd: unmount [%s]", Tcl_GetString(arg))); @@ -686,6 +728,7 @@ static int CookfsUnmountCmd(ClientData clientData, Tcl_Interp *interp, return TCL_OK; } +#ifdef COOKFS_USETCLCMDS // If we were called with -unregister switch, then we are in unregister // callback from tclvfs. Cancel vfs registration status to avoid // double unregistration. @@ -694,6 +737,7 @@ static int CookfsUnmountCmd(ClientData clientData, Tcl_Interp *interp, " cancel tclvfs registration status")); vfs->isRegistered = 0; } +#endif // Try to remove the mount point from mount list CookfsLog(printf("CookfsUnmountCmd: remove the mount point")); @@ -715,7 +759,6 @@ static int CookfsUnmountCmd(ClientData clientData, Tcl_Interp *interp, Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pagesCloseOffset)); - CookfsLog(printf("CookfsUnmountCmd: return ok and [%ld]", pagesCloseOffset)); return TCL_OK; @@ -727,9 +770,11 @@ static void CookfsMountHandleCmdDeleteProc(ClientData clientData) { vfs->commandToken = NULL; } +#ifdef COOKFS_USETCLCMDS static Cookfs_MountHandleCommandProc CookfsMountHandleCommandGetpages; static Cookfs_MountHandleCommandProc CookfsMountHandleCommandGetindex; static Cookfs_MountHandleCommandProc CookfsMountHandleCommandGetwriter; +#endif static Cookfs_MountHandleCommandProc CookfsMountHandleCommandGetmetadata; static Cookfs_MountHandleCommandProc CookfsMountHandleCommandSetmetadata; static Cookfs_MountHandleCommandProc CookfsMountHandleCommandAside; @@ -747,15 +792,19 @@ static int CookfsMountHandleCmd(ClientData clientData, Tcl_Interp *interp, Cookfs_Vfs *vfs = (Cookfs_Vfs *)clientData; static const char *const commands[] = { - "getpages", "getindex", "getwriter", "getmetadata", "setmetadata", - "aside", "writetomemory", "filesize", "smallfilebuffersize", - "compression", "writeFiles", "optimizelist", +#ifdef COOKFS_USETCLCMDS + "getpages", "getindex", "getwriter", +#endif + "getmetadata", "setmetadata", "aside", "writetomemory", "filesize", + "smallfilebuffersize", "compression", "writeFiles", "optimizelist", NULL }; enum commands { - cmdGetpages, cmdGetindex, cmdGetwriter, cmdGetmetadata, cmdSetmetadata, - cmdAside, cmdWritetomemory, cmdFilesize, cmdSmallfilebuffersize, - cmdCompression, cmdWritefiles, cmdOptimizelist +#ifdef COOKFS_USETCLCMDS + cmdGetpages, cmdGetindex, cmdGetwriter, +#endif + cmdGetmetadata, cmdSetmetadata, cmdAside, cmdWritetomemory, cmdFilesize, + cmdSmallfilebuffersize, cmdCompression, cmdWritefiles, cmdOptimizelist }; if (objc < 2) { @@ -771,12 +820,14 @@ static int CookfsMountHandleCmd(ClientData clientData, Tcl_Interp *interp, } switch ((enum commands) command) { +#ifdef COOKFS_USETCLCMDS case cmdGetpages: return CookfsMountHandleCommandGetpages(vfs, interp, objc, objv); case cmdGetindex: return CookfsMountHandleCommandGetindex(vfs, interp, objc, objv); case cmdGetwriter: return CookfsMountHandleCommandGetwriter(vfs, interp, objc, objv); +#endif case cmdGetmetadata: return CookfsMountHandleCommandGetmetadata(vfs, interp, objc, objv); case cmdSetmetadata: @@ -800,6 +851,8 @@ static int CookfsMountHandleCmd(ClientData clientData, Tcl_Interp *interp, return TCL_OK; } +#ifdef COOKFS_USETCLCMDS + static int CookfsMountHandleCommandGetpages(Cookfs_Vfs *vfs, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { @@ -833,6 +886,8 @@ static int CookfsMountHandleCommandGetwriter(Cookfs_Vfs *vfs, Tcl_Interp *interp return TCL_OK; } +#endif + static int CookfsMountHandleCommandGetmetadata(Cookfs_Vfs *vfs, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { diff --git a/generic/vfsVfs.c b/generic/vfsVfs.c index 8903e45..76d5d02 100644 --- a/generic/vfsVfs.c +++ b/generic/vfsVfs.c @@ -150,11 +150,13 @@ Cookfs_Vfs *Cookfs_CookfsRemoveVfs(Tcl_Interp *interp, Tcl_Obj* mountPoint, CookfsLog(printf("Cookfs_CookfsRemoveVfs: the vfs for deletion" " was found")); +#ifdef COOKFS_USETCLCMDS // Unregister the Cookfs from Tclvfs. Tclvfs will call our // Unmount command. It should be able find this mount point and // terminate without error. Thus, this mount point must be in // the mounted state during unregistration in Tclvfs. Cookfs_VfsUnregisterInTclvfs(vfs); +#endif // Remove the mount from the mount chain if (vfsPrev == NULL) { diff --git a/pkgconfig.tcl.in b/pkgconfig.tcl.in index 473815e..2264b19 100644 --- a/pkgconfig.tcl.in +++ b/pkgconfig.tcl.in @@ -15,6 +15,8 @@ proc cookfs::pkgconfig {{command ""} {value ""} {newValue ""}} { c-writerchannel "@COOKFS_PKGCONFIG_USECWRITERCHAN@" c-writer "@COOKFS_PKGCONFIG_USECWRITER@" + tcl-commands "@COOKFS_PKGCONFIG_USETCLCMDS@" + feature-aside "@COOKFS_PKGCONFIG_FEATURE_ASIDE@" feature-bzip2 "@COOKFS_PKGCONFIG_USEBZ2@" feature-xz "@COOKFS_PKGCONFIG_USEXZ@" diff --git a/tests/all.tcl b/tests/all.tcl index 1a64a19..3fc9d70 100644 --- a/tests/all.tcl +++ b/tests/all.tcl @@ -9,7 +9,10 @@ tcltest::temporaryDirectory $tmpdir tcltest::testsDirectory [file dirname [info script]] package require vfs::cookfs -package require vfs + +if { [cookfs::pkgconfig get tcl-commands] } { + package require vfs +} if {[info tclversion] == "8.5"} { package require rechan @@ -41,10 +44,12 @@ tcltest::testConstraint cookfsCompressionZlib 1 tcltest::testConstraint cookfsCompressionBz2 [cookfs::pkgconfig get feature-bzip2] tcltest::testConstraint cookfsCompressionXz [cookfs::pkgconfig get feature-xz] -tcltest::testConstraint enabledCVfs [cookfs::pkgconfig get c-vfs] -tcltest::testConstraint disabledCVfs [expr { ![cookfs::pkgconfig get c-vfs] }] -tcltest::testConstraint enabledCPages [cookfs::pkgconfig get c-pages] -tcltest::testConstraint disabledCPages [expr { ![cookfs::pkgconfig get c-pages] }] +tcltest::testConstraint enabledCVfs [cookfs::pkgconfig get c-vfs] +tcltest::testConstraint disabledCVfs [expr { ![cookfs::pkgconfig get c-vfs] }] +tcltest::testConstraint enabledCPages [cookfs::pkgconfig get c-pages] +tcltest::testConstraint disabledCPages [expr { ![cookfs::pkgconfig get c-pages] }] +tcltest::testConstraint enabledTclCmds [cookfs::pkgconfig get tcl-commands] +tcltest::testConstraint disabledTclCmds [expr { ![cookfs::pkgconfig get tcl-commands] }] tcltest::testConstraint packageTclvfs [expr { ![catch { package present vfs }] }] diff --git a/tests/compression.test b/tests/compression.test index c9347b8..70ccd0e 100644 --- a/tests/compression.test +++ b/tests/compression.test @@ -16,21 +16,21 @@ foreach { cid } { none zlib bz2 xz } { tcltest::makeFile [string repeat "TEST" 1000] \ test4 $dir } -body { - vfs::cookfs::Mount -compression $cid $file $file + cookfs::Mount -compression $cid $file $file file copy -force $dir [file join $file vfs] # remount - vfs::unmount $file - vfs::cookfs::Mount $file $file + cookfs::Unmount $file + cookfs::Mount $file $file set ok [testIfEqual $dir [file join $file vfs]] - vfs::unmount $file + cookfs::Unmount $file set ok } -result 1 -cleanup { - catch { vfs::unmount $file } + catch { cookfs::Unmount $file } file delete -force $file $dir unset -nocomplain ok file dir } - tcltest::test "${test_title}-2" {store uncompressed small data} -constraints $constraint -setup { + tcltest::test "${test_title}-2" {store uncompressed small data} -constraints "$constraint enabledTclCmds" -setup { set file [tcltest::makeFile {} cookfs.cfs] set dir [tcltest::makeDirectory test] tcltest::makeFile "X" test1 $dir @@ -56,7 +56,7 @@ foreach { cid } { none zlib bz2 xz } { unset -nocomplain pg page_size ok file dir } - tcltest::test "${test_title}-3" {store uncompressed large data} -constraints $constraint -setup { + tcltest::test "${test_title}-3" {store uncompressed large data} -constraints "$constraint enabledTclCmds" -setup { set file [tcltest::makeFile {} cookfs.cfs] set dir [tcltest::makeDirectory test] # 128 bytes of random and high entropy data. Any compression should be inefficient with it. @@ -91,7 +91,7 @@ foreach { cid } { none zlib bz2 xz } { unset -nocomplain pg page_size ok file file1 dir fp data } - tcltest::test "${test_title}-4" {store compressed} -constraints $constraint -setup { + tcltest::test "${test_title}-4" {store compressed} -constraints "$constraint enabledTclCmds" -setup { set file [tcltest::makeFile {} cookfs.cfs] set dir [tcltest::makeDirectory test] tcltest::makeFile [string repeat "X" 1024] test1 $dir diff --git a/tests/cookfswriter.test b/tests/cookfswriter.test index 4501360..8324c04 100644 --- a/tests/cookfswriter.test +++ b/tests/cookfswriter.test @@ -2,15 +2,15 @@ tcltest::test cookfsWriter-1.1 "Create empty archive" -constraints runCookfsWrit set file [tcltest::makeFile {} pages.cfs] } -body { cookfs::createArchive $file {} {} - vfs::cookfs::Mount -readonly $file $file - vfs::unmount $file + cookfs::Mount -readonly $file $file + cookfs::Unmount $file } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} catch {file delete -force $file} unset -nocomplain file -} -returnCodes {ok} +} -returnCodes {ok} -match glob -result * -tcltest::test cookfsWriter-1.2 "Create empty archive with bootstrap" -constraints runCookfsWriter -setup { +tcltest::test cookfsWriter-1.2 "Create empty archive with bootstrap" -constraints {runCookfsWriter enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { cookfs::createArchive $file {} {SAMPLE BOOTSTRAP} @@ -26,7 +26,7 @@ tcltest::test cookfsWriter-1.2 "Create empty archive with bootstrap" -constraint unset -nocomplain file p fsid } -returnCodes {ok} -tcltest::test cookfsWriter-1.3 "Create non-empty archive with bootstrap" -constraints runCookfsWriter -setup { +tcltest::test cookfsWriter-1.3 "Create non-empty archive with bootstrap" -constraints {runCookfsWriter enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { diff --git a/tests/dedup.test b/tests/dedup.test index ece5a75..620e480 100644 --- a/tests/dedup.test +++ b/tests/dedup.test @@ -2,7 +2,7 @@ tcltest::test cookfsDedup-1.1 "Large file deduplication" -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set datas [randomDatas 4 8192] - set c [vfs::cookfs::Mount $file $file -compression none \ + set c [cookfs::Mount $file $file -compression none \ -pagesize 4096 -smallfilesize 1024] set i 0 foreach d [concat $datas $datas [lrange $datas 2 14] [lrange $datas 7 15]] { @@ -11,11 +11,11 @@ tcltest::test cookfsDedup-1.1 "Large file deduplication" -setup { puts -nonewline $fh $d close $fh } - vfs::unmount $file + cookfs::Unmount $file set fs [file size $file] expr {($fs > (2048 * 16)) && ($fs < (24 * 2048))} } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file datas c i fh fs d } -result 1 @@ -24,7 +24,7 @@ tcltest::test cookfsDedup-1.2 "Small file deduplication for same resulting pages set file [tcltest::makeFile {} pages.cfs] } -body { set datas [randomDatas 16 2048] - set c [vfs::cookfs::Mount $file $file -compression none \ + set c [cookfs::Mount $file $file -compression none \ -pagesize 16384 -smallfilesize 16384 -smallfilebuffer 16384] set i 0 foreach d [concat $datas $datas $datas $datas] { @@ -33,16 +33,16 @@ tcltest::test cookfsDedup-1.2 "Small file deduplication for same resulting pages puts -nonewline $fh $d close $fh } - vfs::unmount $file + cookfs::Unmount $file set fs [file size $file] expr {($fs > (2048 * 16)) && ($fs < (24 * 2048))} } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file datas c i fh fs d } -result 1 -tcltest::test cookfsDedup-1.3 "Small file deduplication for different resulting pages" -setup { +tcltest::test cookfsDedup-1.3 "Small file deduplication for different resulting pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set datas [randomDatas 4 2048] @@ -89,7 +89,7 @@ file3 * 2048 {1 0 2048} 1 file4 * 2048 {0 0 2048} 1 file5 * 2048 {1 2048 2048} 1} -tcltest::test cookfsDedup-1.4 "Small file deduplication for different resulting pages" -setup { +tcltest::test cookfsDedup-1.4 "Small file deduplication for different resulting pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set datas [randomDatas 3 2048] diff --git a/tests/fsindex.test b/tests/fsindex.test index f5c5628..eb03d94 100644 --- a/tests/fsindex.test +++ b/tests/fsindex.test @@ -1,4 +1,4 @@ -tcltest::test cookfsFsindex-1.1 "Create empty fsindex" -setup { +tcltest::test cookfsFsindex-1.1 "Create empty fsindex" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] } -cleanup { @@ -6,7 +6,7 @@ tcltest::test cookfsFsindex-1.1 "Create empty fsindex" -setup { unset -nocomplain fsidx } -returnCodes {ok} -match glob -result {::cookfs::*::fsindex::handle*} -tcltest::test cookfsFsindex-1.2 "Create empty fsindex and create file" -setup { +tcltest::test cookfsFsindex-1.2 "Create empty fsindex and create file" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx set testfile 2 {0 1 2 3 4 5} @@ -18,7 +18,7 @@ tcltest::test cookfsFsindex-1.2 "Create empty fsindex and create file" -setup { unset -nocomplain fsidx } -returnCodes {ok} -tcltest::test cookfsFsindex-1.3 "Create empty fsindex and create directory and files" -setup { +tcltest::test cookfsFsindex-1.3 "Create empty fsindex and create directory and files" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx set testdir 1 @@ -45,7 +45,7 @@ tcltest::test cookfsFsindex-1.3 "Create empty fsindex and create directory and f unset -nocomplain fsidx } -returnCodes {ok} -tcltest::test cookfsFsindex-2.1 "Create fsindex based on other fsindex" -setup { +tcltest::test cookfsFsindex-2.1 "Create fsindex based on other fsindex" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] @@ -62,7 +62,7 @@ tcltest::test cookfsFsindex-2.1 "Create fsindex based on other fsindex" -setup { unset -nocomplain fsidx fsidx2 } -returnCodes {ok} -result 1,0 -tcltest::test cookfsFsindex-2.2 "Test handling of entries in non-existing paths" -setup { +tcltest::test cookfsFsindex-2.2 "Test handling of entries in non-existing paths" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] @@ -72,7 +72,7 @@ tcltest::test cookfsFsindex-2.2 "Test handling of entries in non-existing paths" unset -nocomplain fsidx } -returnCodes {error} -result {Unable to create entry} -tcltest::test cookfsFsindex-3.1 "Create small number of entries in single directory" -setup { +tcltest::test cookfsFsindex-3.1 "Create small number of entries in single directory" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] for {set i 0} {$i < 10} {incr i} { @@ -95,7 +95,7 @@ tcltest::test cookfsFsindex-3.1 "Create small number of entries in single direct unset -nocomplain fsidx i j d } -returnCodes {ok} -tcltest::test cookfsFsindex-3.2 "Create medium number of entries in single directory" -setup { +tcltest::test cookfsFsindex-3.2 "Create medium number of entries in single directory" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] for {set i 0} {$i < 100} {incr i} { @@ -118,7 +118,7 @@ tcltest::test cookfsFsindex-3.2 "Create medium number of entries in single direc unset -nocomplain fsidx i j d } -returnCodes {ok} -tcltest::test cookfsFsindex-3.3 "Create large number of entries in single directory" -setup { +tcltest::test cookfsFsindex-3.3 "Create large number of entries in single directory" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] for {set i 0} {$i < 1000} {incr i} { @@ -141,7 +141,7 @@ tcltest::test cookfsFsindex-3.3 "Create large number of entries in single direct unset -nocomplain fsidx i j d } -returnCodes {ok} -tcltest::test cookfsFsindex-4.1 "Create filename outside iso8859-1 encoding" -setup { +tcltest::test cookfsFsindex-4.1 "Create filename outside iso8859-1 encoding" -constraints {enabledTclCmds} -setup { } -body { set fn "File\u0105\u4e2d" set fsidx [cookfs::fsindex] @@ -152,7 +152,7 @@ tcltest::test cookfsFsindex-4.1 "Create filename outside iso8859-1 encoding" -se unset -nocomplain fsidx fn } -returnCodes {ok} -result 1 -tcltest::test cookfsFsindex-4.2 "Create filename outside iso8859-1 encoding after export/import" -setup { +tcltest::test cookfsFsindex-4.2 "Create filename outside iso8859-1 encoding after export/import" -constraints {enabledTclCmds} -setup { } -body { set fn "File\u0105\u4e2d" set fsidx [cookfs::fsindex] @@ -166,7 +166,7 @@ tcltest::test cookfsFsindex-4.2 "Create filename outside iso8859-1 encoding afte unset -nocomplain fsidx fn d } -returnCodes {ok} -result 1 -tcltest::test cookfsFsindex-5.1 "Test metadata setting" -constraints cookfsMetadata -setup { +tcltest::test cookfsFsindex-5.1 "Test metadata setting" -constraints {cookfsMetadata enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx setmetadata test1 t0 @@ -178,7 +178,7 @@ tcltest::test cookfsFsindex-5.1 "Test metadata setting" -constraints cookfsMetad unset -nocomplain fsidx } -returnCodes {ok} -result t1,t2 -tcltest::test cookfsFsindex-5.2 "Test metadata setting across export/import" -constraints cookfsMetadata -setup { +tcltest::test cookfsFsindex-5.2 "Test metadata setting across export/import" -constraints {cookfsMetadata enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx setmetadata test1 t0 @@ -194,7 +194,7 @@ tcltest::test cookfsFsindex-5.2 "Test metadata setting across export/import" -co unset -nocomplain fsidx fh d } -returnCodes {ok} -result t1,t2 -tcltest::test cookfsFsindex-6.1 "Test setmtime" -setup { +tcltest::test cookfsFsindex-6.1 "Test setmtime" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx set testdir 1 @@ -205,7 +205,7 @@ tcltest::test cookfsFsindex-6.1 "Test setmtime" -setup { unset -nocomplain fsidx } -returnCodes {ok} -result 3 -tcltest::test cookfsFsindex-6.1 "Test unset for empty directory" -setup { +tcltest::test cookfsFsindex-6.1 "Test unset for empty directory" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx set testdir1 1 @@ -218,7 +218,7 @@ tcltest::test cookfsFsindex-6.1 "Test unset for empty directory" -setup { unset -nocomplain fsidx } -returnCodes {ok} -result testdir1,testdir3 -tcltest::test cookfsFsindex-6.2 "Test unset for empty directory after export and import" -setup { +tcltest::test cookfsFsindex-6.2 "Test unset for empty directory after export and import" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx set testdir1 1 @@ -234,7 +234,7 @@ tcltest::test cookfsFsindex-6.2 "Test unset for empty directory after export and unset -nocomplain fsidx d } -returnCodes {ok} -result testdir1,testdir3 -tcltest::test cookfsFsindex-6.3 "Test unset for file" -setup { +tcltest::test cookfsFsindex-6.3 "Test unset for file" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx set testdir1 1 @@ -250,7 +250,7 @@ tcltest::test cookfsFsindex-6.3 "Test unset for file" -setup { unset -nocomplain fsidx d } -returnCodes {ok} -result testdir1,testdir3 -tcltest::test cookfsFsindex-6.4 "Test unset for non-empty directory" -setup { +tcltest::test cookfsFsindex-6.4 "Test unset for non-empty directory" -constraints {enabledTclCmds} -setup { } -body { set fsidx [cookfs::fsindex] $fsidx set testdir1 1 @@ -263,7 +263,7 @@ tcltest::test cookfsFsindex-6.4 "Test unset for non-empty directory" -setup { unset -nocomplain fsidx } -returnCodes {error} -result {Unable to unset item} -tcltest::test cookfsFsindex-7.1 "Test getblockusage, without arguments" -body { +tcltest::test cookfsFsindex-7.1 "Test getblockusage, without arguments" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx getblockusage } -cleanup { @@ -271,7 +271,7 @@ tcltest::test cookfsFsindex-7.1 "Test getblockusage, without arguments" -body { unset -nocomplain fsidx } -returnCodes error -match glob -result {wrong # args: should be "::cookfs::*::fsindex::handle* getblockusage block"} -tcltest::test cookfsFsindex-7.2 "Test getblockusage, wrong block number" -body { +tcltest::test cookfsFsindex-7.2 "Test getblockusage, wrong block number" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx getblockusage 0 } -cleanup { @@ -279,7 +279,7 @@ tcltest::test cookfsFsindex-7.2 "Test getblockusage, wrong block number" -body { unset -nocomplain fsidx } -result 0 -tcltest::test cookfsFsindex-7.3 "Test getblockusage, after set" -body { +tcltest::test cookfsFsindex-7.3 "Test getblockusage, after set" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx set test1 1 $fsidx set test2 1 {0 1 2 3 4 5} @@ -293,7 +293,7 @@ tcltest::test cookfsFsindex-7.3 "Test getblockusage, after set" -body { unset -nocomplain fsidx } -result [list 1 0 0 1] -tcltest::test cookfsFsindex-7.4 "Test getblockusage, after set and unset" -body { +tcltest::test cookfsFsindex-7.4 "Test getblockusage, after set and unset" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx set test1 1 $fsidx set test2 1 {0 1 2 3 4 5} @@ -308,7 +308,7 @@ tcltest::test cookfsFsindex-7.4 "Test getblockusage, after set and unset" -body unset -nocomplain fsidx } -result [list 0 0 0 0] -tcltest::test cookfsFsindex-7.5 "Test getblockusage, after set, wrong block number" -body { +tcltest::test cookfsFsindex-7.5 "Test getblockusage, after set, wrong block number" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx set test 1 {0 1 2 3 4 5} $fsidx getblockusage 4 @@ -317,7 +317,7 @@ tcltest::test cookfsFsindex-7.5 "Test getblockusage, after set, wrong block numb unset -nocomplain fsidx } -result 0 -tcltest::test cookfsFsindex-7.6 "Test getblockusage, after import" -body { +tcltest::test cookfsFsindex-7.6 "Test getblockusage, after import" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx set testfile2 1 {0 1 2 3 4 5} set d [$fsidx export] @@ -333,7 +333,7 @@ tcltest::test cookfsFsindex-7.6 "Test getblockusage, after import" -body { unset -nocomplain fsidx d } -result [list 1 0 0 1] -tcltest::test cookfsFsindex-7.7 "Test getblockusage, multiple set" -body { +tcltest::test cookfsFsindex-7.7 "Test getblockusage, multiple set" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx set test1 1 {0 1 2 3 4 5} $fsidx set test2 1 @@ -351,7 +351,7 @@ tcltest::test cookfsFsindex-7.7 "Test getblockusage, multiple set" -body { unset -nocomplain fsidx } -result [list 1 0 1 3] -tcltest::test cookfsFsindex-7.8 "Test getblockusage, multiple set/unset" -body { +tcltest::test cookfsFsindex-7.8 "Test getblockusage, multiple set/unset" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx set test1 1 {0 1 2 3 4 5} $fsidx set test2 1 {3 4 5} @@ -373,7 +373,7 @@ tcltest::test cookfsFsindex-7.8 "Test getblockusage, multiple set/unset" -body { unset -nocomplain fsidx } -result [list 1 0 1 2 1] -tcltest::test cookfsFsindex-7.9 "Test getblockusage, set with override" -body { +tcltest::test cookfsFsindex-7.9 "Test getblockusage, set with override" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx set test1 1 {0 1 2 3 4 5} $fsidx set test2 1 {3 4 5} @@ -389,7 +389,7 @@ tcltest::test cookfsFsindex-7.9 "Test getblockusage, set with override" -body { unset -nocomplain fsidx } -result [list 0 0 0 1 1] -tcltest::test cookfsFsindex-8.1 "Test changecount, wrong args" -body { +tcltest::test cookfsFsindex-8.1 "Test changecount, wrong args" -constraints {enabledTclCmds} -body { set fsidx [cookfs::fsindex] $fsidx changecount 1 } -cleanup { @@ -397,7 +397,7 @@ tcltest::test cookfsFsindex-8.1 "Test changecount, wrong args" -body { unset -nocomplain fsidx } -returnCodes error -match glob -result {wrong # args: should be "::cookfs::*::fsindex::handle* changecount"} -tcltest::test cookfsFsindex-8.2 "Test changecount, set/unset increments" -body { +tcltest::test cookfsFsindex-8.2 "Test changecount, set/unset increments" -constraints {enabledTclCmds} -body { set res [list] set fsidx [cookfs::fsindex] lappend res [$fsidx changecount] @@ -422,7 +422,7 @@ tcltest::test cookfsFsindex-8.2 "Test changecount, set/unset increments" -body { unset -nocomplain fsidx res } -result {0 1 2 3 4 5 6 7 8} -tcltest::test cookfsFsindex-8.3 "Test changecount, set/unset metadata increments" -body { +tcltest::test cookfsFsindex-8.3 "Test changecount, set/unset metadata increments" -constraints {enabledTclCmds} -body { set res [list] set fsidx [cookfs::fsindex] lappend res [$fsidx changecount] @@ -435,7 +435,7 @@ tcltest::test cookfsFsindex-8.3 "Test changecount, set/unset metadata increments unset -nocomplain fsidx res } -result {0 1 2} -tcltest::test cookfsFsindex-8.4 "Test changecount, don't increase the counter on unset errors" -body { +tcltest::test cookfsFsindex-8.4 "Test changecount, don't increase the counter on unset errors" -constraints {enabledTclCmds} -body { set res [list] set fsidx [cookfs::fsindex] lappend res [$fsidx changecount] @@ -455,7 +455,7 @@ tcltest::test cookfsFsindex-8.4 "Test changecount, don't increase the counter on unset -nocomplain fsidx res } -result {0 1 2 2 3 4} -tcltest::test cookfsFsindex-8.5 "Test changecount, reset the change counter on import/export" -body { +tcltest::test cookfsFsindex-8.5 "Test changecount, reset the change counter on import/export" -constraints {enabledTclCmds} -body { set res [list] set fsidx [cookfs::fsindex] lappend res [$fsidx changecount] @@ -474,7 +474,7 @@ tcltest::test cookfsFsindex-8.5 "Test changecount, reset the change counter on i unset -nocomplain fsidx res exp } -result {0 1 0 1 0 1} -tcltest::test cookfsFsindex-8.6 "Test changecount, setmtime increment" -body { +tcltest::test cookfsFsindex-8.6 "Test changecount, setmtime increment" -constraints {enabledTclCmds} -body { set res [list] set fsidx [cookfs::fsindex] lappend res [$fsidx changecount] @@ -487,7 +487,7 @@ tcltest::test cookfsFsindex-8.6 "Test changecount, setmtime increment" -body { unset -nocomplain fsidx res } -result {0 1 2} -tcltest::test cookfsFsindex-8.7 "Test changecount, non-incremental operations" -body { +tcltest::test cookfsFsindex-8.7 "Test changecount, non-incremental operations" -constraints {enabledTclCmds} -body { set res [list] set fsidx [cookfs::fsindex] lappend res [$fsidx changecount] @@ -510,7 +510,7 @@ tcltest::test cookfsFsindex-8.7 "Test changecount, non-incremental operations" - unset -nocomplain fsidx res } -result {0 1 2 2 2 2 2 2} -tcltest::test cookfsFsindex-8.8 "Test changecount, don't increment on errors" -body { +tcltest::test cookfsFsindex-8.8 "Test changecount, don't increment on errors" -constraints {enabledTclCmds} -body { set res [list] set fsidx [cookfs::fsindex] lappend res [$fsidx changecount] diff --git a/tests/pages.test b/tests/pages.test index ccc065d..579d40b 100644 --- a/tests/pages.test +++ b/tests/pages.test @@ -1,5 +1,5 @@ -tcltest::test cookfsPages-1.1 "Create empty pages as read-write" -setup { +tcltest::test cookfsPages-1.1 "Create empty pages as read-write" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -9,7 +9,7 @@ tcltest::test cookfsPages-1.1 "Create empty pages as read-write" -setup { unset -nocomplain file pg } -returnCodes {ok} -match glob -result {::cookfs::*::pages::handle*} -tcltest::test cookfsPages-1.2 "Create pages as read-write with existing prefix" -setup { +tcltest::test cookfsPages-1.2 "Create pages as read-write with existing prefix" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set fh [open $file w] @@ -27,7 +27,7 @@ tcltest::test cookfsPages-1.2 "Create pages as read-write with existing prefix" unset -nocomplain file pg fh fc } -returnCodes {ok} -match glob -result {PrefixTest01} -tcltest::test cookfsPages-1.3 "Create pages as read-write with existing prefix and add page" -setup { +tcltest::test cookfsPages-1.3 "Create pages as read-write with existing prefix and add page" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set fh [open $file w] @@ -46,7 +46,7 @@ tcltest::test cookfsPages-1.3 "Create pages as read-write with existing prefix a unset -nocomplain file pg fh fc } -returnCodes {ok} -match glob -result {PrefixTest01} -tcltest::test cookfsPages-1.4 "Create empty pages as read-only" -setup { +tcltest::test cookfsPages-1.4 "Create empty pages as read-only" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -readonly $file] @@ -55,7 +55,7 @@ tcltest::test cookfsPages-1.4 "Create empty pages as read-only" -setup { unset -nocomplain file pg } -returnCodes {error} -match glob -result {Unable to create Cookfs object*} -tcltest::test cookfsPages-1.5 "Check dataoffset command reporting properly for empty files" -setup { +tcltest::test cookfsPages-1.5 "Check dataoffset command reporting properly for empty files" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -74,7 +74,7 @@ tcltest::test cookfsPages-1.5 "Check dataoffset command reporting properly for e unset -nocomplain file pg fh } -returnCodes {ok} -result 15,15,20 -tcltest::test cookfsPages-1.6 "Check dataoffset command reporting properly for files with prefix" -setup { +tcltest::test cookfsPages-1.6 "Check dataoffset command reporting properly for files with prefix" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -94,7 +94,7 @@ tcltest::test cookfsPages-1.6 "Check dataoffset command reporting properly for f unset -nocomplain file pg fh } -returnCodes {ok} -result 4111,4111,4116 -tcltest::test cookfsPages-1.7 "Check filesize command reporting properly for empty archives" -setup { +tcltest::test cookfsPages-1.7 "Check filesize command reporting properly for empty archives" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -110,7 +110,7 @@ tcltest::test cookfsPages-1.7 "Check filesize command reporting properly for emp # -result is 4108 - 4096+1 byte for page prefix+15 bytes for stamp } -returnCodes {ok} -result 4112 -tcltest::test cookfsPages-1.8 "Check filesize command reporting properly for files with prefix" -setup { +tcltest::test cookfsPages-1.8 "Check filesize command reporting properly for files with prefix" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -128,7 +128,7 @@ tcltest::test cookfsPages-1.8 "Check filesize command reporting properly for fil # -result is 8208 - 4096+4096+1 byte for page prefix+15 bytes for stamp } -returnCodes {ok} -result 8208 -tcltest::test cookfsPages-2.1 "Test that different pages get different indexes" -setup { +tcltest::test cookfsPages-2.1 "Test that different pages get different indexes" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -142,7 +142,7 @@ tcltest::test cookfsPages-2.1 "Test that different pages get different indexes" unset -nocomplain file pg i0 i1 } -returnCodes {ok} -result 0 -tcltest::test cookfsPages-2.2 "Test that same pages get same indexes" -setup { +tcltest::test cookfsPages-2.2 "Test that same pages get same indexes" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -156,7 +156,7 @@ tcltest::test cookfsPages-2.2 "Test that same pages get same indexes" -setup { unset -nocomplain file pg i0 i1 } -returnCodes {ok} -result 1 -tcltest::test cookfsPages-2.3 "Test that different pages with same MD5 checksum get different indexes" -setup { +tcltest::test cookfsPages-2.3 "Test that different pages with same MD5 checksum get different indexes" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression none $file] @@ -171,7 +171,7 @@ tcltest::test cookfsPages-2.3 "Test that different pages with same MD5 checksum unset -nocomplain file pg i0 i1 } -returnCodes {ok} -result 0 -tcltest::test cookfsPages-3.1 "Test correctness of pages after write" -setup { +tcltest::test cookfsPages-3.1 "Test correctness of pages after write" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set idxlist {} } -body { @@ -199,7 +199,7 @@ tcltest::test cookfsPages-3.1 "Test correctness of pages after write" -setup { unset -nocomplain file pg idxlist pages p idx } -returnCodes {ok} -tcltest::test cookfsPages-3.2 "Test read-only error for adding a page" -setup { +tcltest::test cookfsPages-3.2 "Test read-only error for adding a page" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression zlib $file] @@ -214,7 +214,7 @@ tcltest::test cookfsPages-3.2 "Test read-only error for adding a page" -setup { unset -nocomplain file pg i0 } -returnCodes {error} -result {Unable to add page} -tcltest::test cookfsPages-3.3 "Test correctness of pages after write - large number of pages" -setup { +tcltest::test cookfsPages-3.3 "Test correctness of pages after write - large number of pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set idxlist {} set conlist {} @@ -242,7 +242,7 @@ tcltest::test cookfsPages-3.3 "Test correctness of pages after write - large num unset -nocomplain file pg idxlist conlist i pr pi pc contents } -returnCodes {ok} -tcltest::test cookfsPages-3.4 "Test correctness of pages writing with same pages" -setup { +tcltest::test cookfsPages-3.4 "Test correctness of pages writing with same pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set idxlist {} } -body { @@ -272,7 +272,7 @@ tcltest::test cookfsPages-3.4 "Test correctness of pages writing with same pages unset -nocomplain file pg idxlist pages p idx } -returnCodes {ok} -tcltest::test cookfsPages-4.1 "Test appended file handling" -constraints cookfsAside -setup { +tcltest::test cookfsPages-4.1 "Test appended file handling" -constraints {cookfsAside enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set file2 [tcltest::makeFile {} pages2.cfs] } -body { @@ -314,7 +314,7 @@ tcltest::test cookfsPages-4.1 "Test appended file handling" -constraints cookfsA unset -nocomplain file pg file2 i0 i1 s1 s0 } -returnCodes {ok} -tcltest::test cookfsPages-4.2 "Test appended file handling - adding same page to new archive" -constraints cookfsAside -setup { +tcltest::test cookfsPages-4.2 "Test appended file handling - adding same page to new archive" -constraints {cookfsAside enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set file2 [tcltest::makeFile {} pages2.cfs] } -body { @@ -371,7 +371,7 @@ tcltest::test cookfsPages-4.2 "Test appended file handling - adding same page to unset -nocomplain file pg file2 i0 i1 i2 i3 i4 s1 s0 } -returnCodes {ok} -tcltest::test cookfsPages-5.1 "Test specifying -endoffset" -setup { +tcltest::test cookfsPages-5.1 "Test specifying -endoffset" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression zlib $file] @@ -414,7 +414,7 @@ tcltest::test cookfsPages-5.1 "Test specifying -endoffset" -setup { unset -nocomplain file pg i0 size fh err } -returnCodes {ok} -tcltest::test cookfsPages-5.2.1 "Check searching for end of archive if endoffset not specified for small file, 256 bytes of garbage at the end of the file" -setup { +tcltest::test cookfsPages-5.2.1 "Check searching for end of archive if endoffset not specified for small file, 256 bytes of garbage at the end of the file" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -437,7 +437,7 @@ tcltest::test cookfsPages-5.2.1 "Check searching for end of archive if endoffset unset -nocomplain file pg fh } -returnCodes {ok} -result 15; # 15 is the size of stamp -tcltest::test cookfsPages-5.2.2 "Check searching for end of archive if endoffset not specified for small file, 65500 bytes of garbage at the end of the file" -setup { +tcltest::test cookfsPages-5.2.2 "Check searching for end of archive if endoffset not specified for small file, 65500 bytes of garbage at the end of the file" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -460,7 +460,7 @@ tcltest::test cookfsPages-5.2.2 "Check searching for end of archive if endoffset unset -nocomplain file pg fh } -returnCodes {ok} -result 15; # 15 is the size of stamp -tcltest::test cookfsPages-5.3.1 "Check searching for end of archive if endoffset not specified for large file, 256 bytes of garbage at the end of the file" -setup { +tcltest::test cookfsPages-5.3.1 "Check searching for end of archive if endoffset not specified for large file, 256 bytes of garbage at the end of the file" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -483,7 +483,7 @@ tcltest::test cookfsPages-5.3.1 "Check searching for end of archive if endoffset unset -nocomplain file pg fh } -returnCodes {ok} -result 15; # 15 is the size of stamp -tcltest::test cookfsPages-5.3.2 "Check searching for end of archive if endoffset not specified for large file, 65500 bytes of garbage at the end of the file" -setup { +tcltest::test cookfsPages-5.3.2 "Check searching for end of archive if endoffset not specified for large file, 65500 bytes of garbage at the end of the file" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] @@ -506,7 +506,7 @@ tcltest::test cookfsPages-5.3.2 "Check searching for end of archive if endoffset unset -nocomplain file pg fh } -returnCodes {ok} -result 15; # 15 is the size of stamp -tcltest::test cookfsPages-6.1 "Test multiple compression algorithms" -setup { +tcltest::test cookfsPages-6.1 "Test multiple compression algorithms" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression none $file] @@ -558,7 +558,7 @@ tcltest::test cookfsPages-6.1 "Test multiple compression algorithms" -setup { unset -nocomplain file pg i0 fs0 fs1 i i1 } -returnCodes {ok} -tcltest::test cookfsPages-7.1 "Test custom compression algorithm" -setup { +tcltest::test cookfsPages-7.1 "Test custom compression algorithm" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression custom -compresscommand testcompress -decompresscommand testdecompress $file] @@ -585,7 +585,7 @@ tcltest::test cookfsPages-7.1 "Test custom compression algorithm" -setup { testcompresscleanup } -returnCodes {ok} -tcltest::test cookfsPages-7.2 "Test custom compression algorithm - no decompress command error" -setup { +tcltest::test cookfsPages-7.2 "Test custom compression algorithm - no decompress command error" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression custom -compresscommand testcompress $file] @@ -601,7 +601,7 @@ tcltest::test cookfsPages-7.2 "Test custom compression algorithm - no decompress testcompresscleanup } -returnCodes {error} -result {Unable to retrieve chunk} -tcltest::test cookfsPages-7.3 "Test custom compression algorithm - no decompress command error when adding same page" -setup { +tcltest::test cookfsPages-7.3 "Test custom compression algorithm - no decompress command error when adding same page" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression custom -compresscommand testcompress $file] @@ -614,7 +614,7 @@ tcltest::test cookfsPages-7.3 "Test custom compression algorithm - no decompress testcompresscleanup } -returnCodes {error} -result {No decompresscommand specified} -tcltest::test cookfsPages-7.4 "Test custom compression algorithm not used when size would not be smaller" -setup { +tcltest::test cookfsPages-7.4 "Test custom compression algorithm not used when size would not be smaller" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression custom -compresscommand testcompress -decompresscommand testdecompress $file] @@ -642,7 +642,7 @@ tcltest::test cookfsPages-7.4 "Test custom compression algorithm not used when s testcompresscleanup } -returnCodes {ok} -tcltest::test cookfsPages-7.5 "Test custom compression algorithm not used when size would not be smaller with -alwayscompress" -setup { +tcltest::test cookfsPages-7.5 "Test custom compression algorithm not used when size would not be smaller with -alwayscompress" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression custom -compresscommand testcompress -decompresscommand testdecompress -alwayscompress $file] @@ -670,7 +670,7 @@ tcltest::test cookfsPages-7.5 "Test custom compression algorithm not used when s testcompresscleanup } -returnCodes {ok} -tcltest::test cookfsPages-8.1 "Test returning offset to end of file during close without changes" -setup { +tcltest::test cookfsPages-8.1 "Test returning offset to end of file during close without changes" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -683,7 +683,7 @@ tcltest::test cookfsPages-8.1 "Test returning offset to end of file during close unset -nocomplain file pg offset } -returnCodes {ok} -result 1 -tcltest::test cookfsPages-8.2 "Test returning offset to end of file during close with changes" -setup { +tcltest::test cookfsPages-8.2 "Test returning offset to end of file during close with changes" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -697,7 +697,7 @@ tcltest::test cookfsPages-8.2 "Test returning offset to end of file during close unset -nocomplain file pg offset } -returnCodes {ok} -result 1 -tcltest::test cookfsPages-8.3 "Test returning offset to end of file during close without changes when remounting" -setup { +tcltest::test cookfsPages-8.3 "Test returning offset to end of file during close without changes when remounting" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -714,7 +714,7 @@ tcltest::test cookfsPages-8.3 "Test returning offset to end of file during close unset -nocomplain file pg offset } -returnCodes {ok} -result 1 -tcltest::test cookfsPages-8.4 "Test returning offset when overwriting appended data" -setup { +tcltest::test cookfsPages-8.4 "Test returning offset when overwriting appended data" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -742,7 +742,7 @@ tcltest::test cookfsPages-8.4 "Test returning offset when overwriting appended d unset -nocomplain file pg fh i offset idx } -returnCodes {ok} -result 1025 -tcltest::test cookfsPages-9.1.1 "Test only changing index information" -setup { +tcltest::test cookfsPages-9.1.1 "Test only changing index information" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -763,7 +763,7 @@ tcltest::test cookfsPages-9.1.1 "Test only changing index information" -setup { unset -nocomplain file pg offset } -returnCodes {ok} -result IDX1 -tcltest::test cookfsPages-9.1.2 "Test only changing index information without pages" -setup { +tcltest::test cookfsPages-9.1.2 "Test only changing index information without pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set result [list] @@ -786,7 +786,7 @@ tcltest::test cookfsPages-9.1.2 "Test only changing index information without pa unset -nocomplain file pg result offset } -returnCodes {ok} -result {IDX0 IDX1} -tcltest::test cookfsPages-10.1 "Test crc32 checksum algorithm" -setup { +tcltest::test cookfsPages-10.1 "Test crc32 checksum algorithm" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -805,7 +805,7 @@ tcltest::test cookfsPages-10.1 "Test crc32 checksum algorithm" -setup { # this test doesn't catch a failure. Thus, it should be disabled when # c-pages feature is not enabled or md5 package is not available. tcltest::test cookfsPages-10.2 "Test crc32 checksum algorithm fail if not re-set" -constraints { - [cookfs::pkgconfig get c-pages] || ![catch { package require md5 2 }] + ([cookfs::pkgconfig get c-pages] || ![catch { package require md5 2 }]) && [cookfs::pkgconfig get tcl-commands] } -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { @@ -823,7 +823,7 @@ tcltest::test cookfsPages-10.2 "Test crc32 checksum algorithm fail if not re-set unset -nocomplain file pg i0 i1 } -returnCodes {ok} -result 1 -tcltest::test cookfsPages-10.3 "Test crc32 checksum algorithm after re-reading" -setup { +tcltest::test cookfsPages-10.3 "Test crc32 checksum algorithm after re-reading" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {TESTTEST} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -841,7 +841,7 @@ tcltest::test cookfsPages-10.3 "Test crc32 checksum algorithm after re-reading" unset -nocomplain file pg i0 i1 } -returnCodes {ok} -result 1 -tcltest::test cookfsPages-10.4 "Test crc32 with large chunks" -setup { +tcltest::test cookfsPages-10.4 "Test crc32 with large chunks" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression custom -compresscommand testcompress $file] @@ -855,7 +855,7 @@ tcltest::test cookfsPages-10.4 "Test crc32 with large chunks" -setup { testcompresscleanup } -returnCodes {error} -result {No decompresscommand specified} -tcltest::test cookfsPages-11.1 "Test increasing page cache" -setup { +tcltest::test cookfsPages-11.1 "Test increasing page cache" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set il {} } -body { @@ -879,7 +879,7 @@ tcltest::test cookfsPages-11.1 "Test increasing page cache" -setup { testcompresscleanup } -returnCodes {ok} -result 20 -tcltest::test cookfsPages-11.2 "Test decreasing page cache" -setup { +tcltest::test cookfsPages-11.2 "Test decreasing page cache" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set il {} } -body { @@ -909,7 +909,7 @@ tcltest::test cookfsPages-11.2 "Test decreasing page cache" -setup { testcompresscleanup } -returnCodes {ok} -result 20 -tcltest::test cookfsPages-12.1 "Test changing page compression" -setup { +tcltest::test cookfsPages-12.1 "Test changing page compression" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression zlib $file] @@ -946,7 +946,7 @@ tcltest::test cookfsPages-12.1 "Test changing page compression" -setup { unset -nocomplain file pg i il fh fc } -returnCodes {ok} -tcltest::test cookfsPages-12.2 "Test getting current page compression" -setup { +tcltest::test cookfsPages-12.2 "Test getting current page compression" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -compression zlib $file] @@ -969,7 +969,7 @@ tcltest::test cookfsPages-12.2 "Test getting current page compression" -setup { unset -nocomplain file pg } -returnCodes {ok} -tcltest::test cookfsPages-13.1 "Error message when index not found" -setup { +tcltest::test cookfsPages-13.1 "Error message when index not found" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages -readonly $file] @@ -979,7 +979,7 @@ tcltest::test cookfsPages-13.1 "Error message when index not found" -setup { unset -nocomplain file pg } -returnCodes {error} -match glob -result {Unable to create Cookfs object: index not found} -tcltest::test cookfsPages-13.2.1 "Error message when invalid signature found" -setup { +tcltest::test cookfsPages-13.2.1 "Error message when invalid signature found" -constraints {enabledTclCmds} -setup { set file [tcltest::makeBinFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add [string repeat TEST 32] @@ -1002,7 +1002,7 @@ tcltest::test cookfsPages-13.2.1 "Error message when invalid signature found" -s unset -nocomplain file pg fh fc } -returnCodes {error} -match glob -result {The archive "*" appears to be corrupted or truncated. Expected archive size is 180 bytes or larger.} -tcltest::test cookfsPages-13.2.2 "Error message for truncated file with 100 bytes before archive" -setup { +tcltest::test cookfsPages-13.2.2 "Error message for truncated file with 100 bytes before archive" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set fp [open $file wb] seek $fp 99 start @@ -1023,7 +1023,7 @@ tcltest::test cookfsPages-13.2.2 "Error message for truncated file with 100 byte unset -nocomplain file pg fh fp } -returnCodes {error} -match glob -result {The archive "*" appears to be corrupted or truncated. Expected archive size is 1176 bytes or larger.} -tcltest::test cookfsPages-13.2.3 "Error message for truncated file with 9MB bytes before archive" -setup { +tcltest::test cookfsPages-13.2.3 "Error message for truncated file with 9MB bytes before archive" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set fp [open $file wb] seek $fp [expr { 1024 * 1024 * 9 - 1}] start @@ -1046,7 +1046,7 @@ tcltest::test cookfsPages-13.2.3 "Error message for truncated file with 9MB byte # We are looking for no more than 10 mb, so this test should not find the stamp # and give a generic "invalid file signature" error message. -tcltest::test cookfsPages-13.2.4 "Error message for truncated file with 10MB bytes before archive" -setup { +tcltest::test cookfsPages-13.2.4 "Error message for truncated file with 10MB bytes before archive" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set fp [open $file wb] seek $fp [expr { 1024 * 1024 * 10 - 1}] start @@ -1067,7 +1067,7 @@ tcltest::test cookfsPages-13.2.4 "Error message for truncated file with 10MB byt unset -nocomplain file pg fp fh } -returnCodes {error} -match glob -result {Unable to create Cookfs object: invalid file signature} -tcltest::test cookfsPages-13.2.5 "Error message for truncated file with 1024 bytes before archive, without pages and updated fsindex" -setup { +tcltest::test cookfsPages-13.2.5 "Error message for truncated file with 1024 bytes before archive, without pages and updated fsindex" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set fp [open $file wb] seek $fp 1023 start @@ -1088,7 +1088,7 @@ tcltest::test cookfsPages-13.2.5 "Error message for truncated file with 1024 byt unset -nocomplain file pg fp fh } -returnCodes {error} -match glob -result {The archive "*" appears to be corrupted or truncated. Expected archive size is 2080 bytes or larger.} -tcltest::test cookfsPages-13.3 "Error message when unable to seek to pages" -setup { +tcltest::test cookfsPages-13.3 "Error message when unable to seek to pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 1 @@ -1116,7 +1116,7 @@ tcltest::test cookfsPages-13.3 "Error message when unable to seek to pages" -set unset -nocomplain file pg size fh fc } -returnCodes {error} -match glob -result {Unable to create Cookfs object: page sizes not found} -tcltest::test cookfsPages-13.4 "Error message when specifying invalid -endoffset" -setup { +tcltest::test cookfsPages-13.4 "Error message when specifying invalid -endoffset" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 1 @@ -1133,7 +1133,7 @@ tcltest::test cookfsPages-13.4 "Error message when specifying invalid -endoffset } -returnCodes {error} -match glob -result {Unable to create Cookfs object: index not found} # TODO: this test should generate same results in Tcl and C version of the library -tcltest::test cookfsPages-13.5 "Error message when specifying directory" -setup { +tcltest::test cookfsPages-13.5 "Error message when specifying directory" -constraints {enabledTclCmds} -setup { set file [tcltest::makeDirectory pages.cfs] } -body { set pg [cookfs::pages -readonly $file] @@ -1143,7 +1143,7 @@ tcltest::test cookfsPages-13.5 "Error message when specifying directory" -setup unset -nocomplain file pg } -returnCodes {error} -match glob -result {Unable to create Cookfs object: *} -tcltest::test cookfsPages-13.6.1 "Error message when specifying directory and -endoffset" -constraints unix -setup { +tcltest::test cookfsPages-13.6.1 "Error message when specifying directory and -endoffset" -constraints {unix enabledTclCmds} -setup { set file [tcltest::makeDirectory pages.cfs] } -body { set pg [cookfs::pages -endoffset 1 -readonly $file] @@ -1153,7 +1153,7 @@ tcltest::test cookfsPages-13.6.1 "Error message when specifying directory and -e unset -nocomplain file pg } -returnCodes {error} -match glob -result {Unable to create Cookfs object: index not found} -tcltest::test cookfsPages-13.6.2 "Error message when specifying directory and -endoffset" -constraints win -setup { +tcltest::test cookfsPages-13.6.2 "Error message when specifying directory and -endoffset" -constraints {win enabledTclCmds} -setup { set file [tcltest::makeDirectory pages.cfs] } -body { set pg [cookfs::pages -endoffset 1 -readonly $file] @@ -1163,7 +1163,7 @@ tcltest::test cookfsPages-13.6.2 "Error message when specifying directory and -e unset -nocomplain file pg } -returnCodes {error} -match glob -result {Unable to create Cookfs object: couldn't open "*": permission denied} -tcltest::test cookfsPages-13.7 "Error message when specifying non-existing file" -setup { +tcltest::test cookfsPages-13.7 "Error message when specifying non-existing file" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] file delete -force $file } -body { @@ -1174,7 +1174,7 @@ tcltest::test cookfsPages-13.7 "Error message when specifying non-existing file" unset -nocomplain file pg } -returnCodes {error} -match glob -result {Unable to create Cookfs object: couldn't open "*": no such file or directory} -tcltest::test cookfsPages-13.8.1 "Error message when specifying wrong # arg for 'page get'" -setup { +tcltest::test cookfsPages-13.8.1 "Error message when specifying wrong # arg for 'page get'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1185,7 +1185,7 @@ tcltest::test cookfsPages-13.8.1 "Error message when specifying wrong # arg for unset -nocomplain file pg } -returnCodes {error} -match glob -result {wrong # args: should be "::cookfs::*::pages::handle* get ?-weight weight? index"} -tcltest::test cookfsPages-13.8.2 "Error message when specifying wrong # arg for 'page get'" -setup { +tcltest::test cookfsPages-13.8.2 "Error message when specifying wrong # arg for 'page get'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1196,7 +1196,7 @@ tcltest::test cookfsPages-13.8.2 "Error message when specifying wrong # arg for unset -nocomplain file pg } -returnCodes {error} -match glob -result {wrong # args: should be "::cookfs::*::pages::handle* get ?-weight weight? index"} -tcltest::test cookfsPages-13.8.3 "Error message when specifying wrong # arg for 'page get'" -setup { +tcltest::test cookfsPages-13.8.3 "Error message when specifying wrong # arg for 'page get'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1207,7 +1207,7 @@ tcltest::test cookfsPages-13.8.3 "Error message when specifying wrong # arg for unset -nocomplain file pg } -returnCodes {error} -match glob -result {wrong # args: should be "::cookfs::*::pages::handle* get ?-weight weight? index"} -tcltest::test cookfsPages-13.8.4 "Error message when specifying wrong arg format for 'page get'" -setup { +tcltest::test cookfsPages-13.8.4 "Error message when specifying wrong arg format for 'page get'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1218,7 +1218,7 @@ tcltest::test cookfsPages-13.8.4 "Error message when specifying wrong arg format unset -nocomplain file pg } -returnCodes {error} -result {expected integer but got "not-a-num1"} -tcltest::test cookfsPages-13.8.5 "Error message when specifying wrong arg format for 'page get'" -setup { +tcltest::test cookfsPages-13.8.5 "Error message when specifying wrong arg format for 'page get'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1229,7 +1229,7 @@ tcltest::test cookfsPages-13.8.5 "Error message when specifying wrong arg format unset -nocomplain file pg } -returnCodes {error} -result {expected integer but got "not-a-num2"} -tcltest::test cookfsPages-13.9.1 "Error message when specifying wrong # args for 'page ticktock'" -setup { +tcltest::test cookfsPages-13.9.1 "Error message when specifying wrong # args for 'page ticktock'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1240,7 +1240,7 @@ tcltest::test cookfsPages-13.9.1 "Error message when specifying wrong # args for unset -nocomplain file pg } -returnCodes {error} -match glob -result {wrong # args: should be "::cookfs::*::pages::handle* ticktock ?maxAge?"} -tcltest::test cookfsPages-13.9.2 "Error message when specifying wrong arg format for 'page ticktock'" -setup { +tcltest::test cookfsPages-13.9.2 "Error message when specifying wrong arg format for 'page ticktock'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1251,7 +1251,7 @@ tcltest::test cookfsPages-13.9.2 "Error message when specifying wrong arg format unset -nocomplain file pg } -returnCodes {error} -result {expected integer but got "not-a-num3"} -tcltest::test cookfsPages-13.10.1 "Error message when specifying wrong # args for 'page getcache'" -setup { +tcltest::test cookfsPages-13.10.1 "Error message when specifying wrong # args for 'page getcache'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1262,7 +1262,7 @@ tcltest::test cookfsPages-13.10.1 "Error message when specifying wrong # args fo unset -nocomplain file pg } -returnCodes {error} -match glob -result {wrong # args: should be "::cookfs::*::pages::handle* getcache ?index?"} -tcltest::test cookfsPages-13.10.2 "Error message when specifying wrong arg format for 'page getcache'" -setup { +tcltest::test cookfsPages-13.10.2 "Error message when specifying wrong arg format for 'page getcache'" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1273,7 +1273,7 @@ tcltest::test cookfsPages-13.10.2 "Error message when specifying wrong arg forma unset -nocomplain file pg } -returnCodes {error} -result {expected integer but got "not-a-num4"} -tcltest::test cookfsPages-14.1 "Cache is empty on open" -setup { +tcltest::test cookfsPages-14.1 "Cache is empty on open" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] } -body { set pg [cookfs::pages $file] @@ -1284,7 +1284,7 @@ tcltest::test cookfsPages-14.1 "Cache is empty on open" -setup { unset -nocomplain file pg } -result "" -tcltest::test cookfsPages-14.2 "Check that getcache returns a dict value with expected keys" -setup { +tcltest::test cookfsPages-14.2 "Check that getcache returns a dict value with expected keys" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 @@ -1306,7 +1306,7 @@ tcltest::test cookfsPages-14.2 "Check that getcache returns a dict value with ex unset -nocomplain file pg x k v } -result {{age-0 index-0 weight-0}} -tcltest::test cookfsPages-14.3 "Cache contains exactly the 2nd page" -setup { +tcltest::test cookfsPages-14.3 "Cache contains exactly the 2nd page" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 @@ -1326,7 +1326,7 @@ tcltest::test cookfsPages-14.3 "Cache contains exactly the 2nd page" -setup { unset -nocomplain file pg x } -result "1" -tcltest::test cookfsPages-14.4 "Cache contains exactly two pages" -setup { +tcltest::test cookfsPages-14.4 "Cache contains exactly two pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 @@ -1342,7 +1342,7 @@ tcltest::test cookfsPages-14.4 "Cache contains exactly two pages" -setup { unset -nocomplain file pg x } -result "1 0" -tcltest::test cookfsPages-14.5 "Cache contains exactly three pages in specific order" -setup { +tcltest::test cookfsPages-14.5 "Cache contains exactly three pages in specific order" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 @@ -1363,7 +1363,7 @@ tcltest::test cookfsPages-14.5 "Cache contains exactly three pages in specific o unset -nocomplain file pg x } -result "3 0 4" -tcltest::test cookfsPages-15.1 "Check if the cache weight is stored correctly" -setup { +tcltest::test cookfsPages-15.1 "Check if the cache weight is stored correctly" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 @@ -1385,7 +1385,7 @@ tcltest::test cookfsPages-15.1 "Check if the cache weight is stored correctly" - unset -nocomplain file pg x } -result {{3 0} {0 -5} {4 20} {1 0}} -tcltest::test cookfsPages-15.2 "Check if the cache entry with minimum weight is evicted" -setup { +tcltest::test cookfsPages-15.2 "Check if the cache entry with minimum weight is evicted" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 @@ -1460,7 +1460,7 @@ tcltest::test cookfsPages-15.2 "Check if the cache entry with minimum weight is {1 -1} {3 0} {0 5} {4 20} {2 0} {3 0} {0 5} {4 20}} -tcltest::test cookfsPages-16.1 "Check if the cache age is stored correctly" -setup { +tcltest::test cookfsPages-16.1 "Check if the cache age is stored correctly" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 @@ -1547,7 +1547,7 @@ tcltest::test cookfsPages-16.1 "Check if the cache age is stored correctly" -set {4 1 0} {3 1 0} {2 2 0} {0 5 0} {1 0 0} {4 1 0} {3 1 0} {2 2 0}} -tcltest::test cookfsPages-17.1 "Check if cache checking is working properly" -setup { +tcltest::test cookfsPages-17.1 "Check if cache checking is working properly" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set pg [cookfs::pages -compression none $file] $pg add 0; $pg add 1; $pg add 2; $pg add 3; $pg add 4 diff --git a/tests/pagesAsync.test b/tests/pagesAsync.test index 9208266..5b651d8 100644 --- a/tests/pagesAsync.test +++ b/tests/pagesAsync.test @@ -1,4 +1,4 @@ -tcltest::test cookfsPagesAsync-1.1 "Ensure asynccompresscommand is called when no pages are created" -setup { +tcltest::test cookfsPagesAsync-1.1 "Ensure asynccompresscommand is called when no pages are created" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -14,7 +14,7 @@ tcltest::test cookfsPagesAsync-1.1 "Ensure asynccompresscommand is called when n testasynccleanup } -returnCodes {ok} -result 1 -tcltest::test cookfsPagesAsync-1.2 "Ensure asynccompresscommand finalize is called when no pages are created" -setup { +tcltest::test cookfsPagesAsync-1.2 "Ensure asynccompresscommand finalize is called when no pages are created" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set ::testasynccompressfinalized 0 testasynccompress init 4 {} @@ -31,7 +31,7 @@ tcltest::test cookfsPagesAsync-1.2 "Ensure asynccompresscommand finalize is call testasynccleanup } -returnCodes {ok} -result 1 -tcltest::test cookfsPagesAsync-1.3 "Create single page using async approach" -setup { +tcltest::test cookfsPagesAsync-1.3 "Create single page using async approach" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -47,7 +47,7 @@ tcltest::test cookfsPagesAsync-1.3 "Create single page using async approach" -se testasynccleanup } -returnCodes {ok} -result 1 -tcltest::test cookfsPagesAsync-1.4 "Create single page and delete pages object using async approach" -setup { +tcltest::test cookfsPagesAsync-1.4 "Create single page and delete pages object using async approach" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -64,7 +64,7 @@ tcltest::test cookfsPagesAsync-1.4 "Create single page and delete pages object u testasynccleanup } -returnCodes {ok} -result 2 -tcltest::test cookfsPagesAsync-1.5 "Verify async page can be read" -setup { +tcltest::test cookfsPagesAsync-1.5 "Verify async page can be read" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -83,7 +83,7 @@ tcltest::test cookfsPagesAsync-1.5 "Verify async page can be read" -setup { testasynccleanup } -returnCodes {ok} -result "SAMPLE DATA SAMPLE DATA SAMPLE DATA" -tcltest::test cookfsPagesAsync-1.6 "Verify multiple async pages can be read" -setup { +tcltest::test cookfsPagesAsync-1.6 "Verify multiple async pages can be read" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -111,7 +111,7 @@ tcltest::test cookfsPagesAsync-1.6 "Verify multiple async pages can be read" -se testasynccleanup } -returnCodes {ok} -result 1024 -tcltest::test cookfsPagesAsync-1.7 "Verify multiple async pages with repetitions can be read" -setup { +tcltest::test cookfsPagesAsync-1.7 "Verify multiple async pages with repetitions can be read" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -139,7 +139,7 @@ tcltest::test cookfsPagesAsync-1.7 "Verify multiple async pages with repetitions testasynccleanup } -returnCodes {ok} -result 512 -tcltest::test cookfsPagesAsync-2.1 "Test custom async compression algorithm not used when size would not be smaller" -setup { +tcltest::test cookfsPagesAsync-2.1 "Test custom async compression algorithm not used when size would not be smaller" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -170,7 +170,7 @@ tcltest::test cookfsPagesAsync-2.1 "Test custom async compression algorithm not testasynccleanup } -returnCodes {ok} -tcltest::test cookfsPagesAsync-2.2 "Test custom async compression algorithm used when size would not be smaller with -alwayscompress" -setup { +tcltest::test cookfsPagesAsync-2.2 "Test custom async compression algorithm used when size would not be smaller with -alwayscompress" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} } -body { @@ -202,7 +202,7 @@ tcltest::test cookfsPagesAsync-2.2 "Test custom async compression algorithm used testasynccleanup } -returnCodes {ok} -tcltest::test cookfsPagesAsync-3.1 "Test correctness of async pages writing with adding same pages" -setup { +tcltest::test cookfsPagesAsync-3.1 "Test correctness of async pages writing with adding same pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] testasynccompress init 4 {} set idxlist {} @@ -237,7 +237,7 @@ tcltest::test cookfsPagesAsync-3.1 "Test correctness of async pages writing with testasynccleanup } -returnCodes {ok} -tcltest::test cookfsPagesAsync-4.1 "Verify async decompression does not call decompress command for subsequent pages" -setup { +tcltest::test cookfsPagesAsync-4.1 "Verify async decompression does not call decompress command for subsequent pages" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set idxlist {} testasyncdecompress init 4 {} @@ -272,7 +272,7 @@ tcltest::test cookfsPagesAsync-4.1 "Verify async decompression does not call dec testasynccleanup } -returnCodes {ok} -result 0 -tcltest::test cookfsPagesAsync-4.2 "Verify async decompression does not call decompress command for subsequent pages with random return order" -setup { +tcltest::test cookfsPagesAsync-4.2 "Verify async decompression does not call decompress command for subsequent pages with random return order" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set idxlist {} testasyncdecompress init 4 {} @@ -307,7 +307,7 @@ tcltest::test cookfsPagesAsync-4.2 "Verify async decompression does not call dec testasynccleanup } -returnCodes {ok} -result 0 -tcltest::test cookfsPagesAsync-4.3 "Verify async decompression does not async decompress multiple times" -setup { +tcltest::test cookfsPagesAsync-4.3 "Verify async decompression does not async decompress multiple times" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] set idxlist {} testasyncdecompress init 4 {} diff --git a/tests/pkgconfig.test b/tests/pkgconfig.test index 820ceb5..c08a5f3 100644 --- a/tests/pkgconfig.test +++ b/tests/pkgconfig.test @@ -28,4 +28,5 @@ feature-bzip2 bool feature-metadata bool feature-xz bool package-version version +tcl-commands bool } diff --git a/tests/readerchannel.test b/tests/readerchannel.test index 3457554..7895b14 100644 --- a/tests/readerchannel.test +++ b/tests/readerchannel.test @@ -1,5 +1,5 @@ -tcltest::test cookfsReaderChannel-1 {read from multiple pages} -setup { +tcltest::test cookfsReaderChannel-1 {read from multiple pages} -constraints {enabledTclCmds} -setup { set vfs [tcltest::makeFile {} cookfs.cfs] # page size is 899 bytes vfs::cookfs::Mount -compression none -pagesize 899 -smallfilesize 1 -smallfilebuffer 0 $vfs $vfs @@ -37,13 +37,13 @@ tcltest::test cookfsReaderChannel-1 {read from multiple pages} -setup { tcltest::test cookfsReaderChannel-2 {full read with multiple pages} -setup { set vfs [tcltest::makeFile {} cookfs.cfs] # page size is 899 bytes - vfs::cookfs::Mount -compression none -pagesize 899 -smallfilesize 1 -smallfilebuffer 0 $vfs $vfs + cookfs::Mount -compression none -pagesize 899 -smallfilesize 1 -smallfilebuffer 0 $vfs $vfs set data "[string repeat "TEST" 1000]\n" # 4x1000+ = 4001 bytes set file [tcltest::makeFile $data test $vfs] - vfs::unmount $vfs + cookfs::Unmount $vfs } -body { - vfs::cookfs::Mount -readonly $vfs $vfs + cookfs::Mount -readonly $vfs $vfs set result "" set fp [open $file r] fconfigure $fp -translation binary -encoding binary @@ -51,10 +51,10 @@ tcltest::test cookfsReaderChannel-2 {full read with multiple pages} -setup { append result [read $fp 11] } close $fp - vfs::unmount $vfs + cookfs::Unmount $vfs list [string length $result] [expr { $result eq $data }] } -result {4001 1} -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } file delete -force $vfs unset -nocomplain result fp vfs file data } @@ -62,13 +62,13 @@ tcltest::test cookfsReaderChannel-2 {full read with multiple pages} -setup { tcltest::test cookfsReaderChannel-3 {position when reading a file sequentially over several pages} -setup { set vfs [tcltest::makeFile {} cookfs.cfs] # page size is 899 bytes - vfs::cookfs::Mount -compression none -pagesize 899 -smallfilesize 1 -smallfilebuffer 0 $vfs $vfs + cookfs::Mount -compression none -pagesize 899 -smallfilesize 1 -smallfilebuffer 0 $vfs $vfs set data "[string repeat "TEST" 1000]\n" # 4x1000+ = 4001 bytes set file [tcltest::makeFile $data test $vfs] - vfs::unmount $vfs + cookfs::Unmount $vfs } -body { - vfs::cookfs::Mount -readonly $vfs $vfs + cookfs::Mount -readonly $vfs $vfs set result [list] set expected 0 set fp [open $file r] @@ -79,7 +79,7 @@ tcltest::test cookfsReaderChannel-3 {position when reading a file sequentially o lappend result "[tell $fp] $expected" } close $fp - vfs::unmount $vfs + cookfs::Unmount $vfs join $result \n } -result {800 800 1600 1600 @@ -87,7 +87,7 @@ tcltest::test cookfsReaderChannel-3 {position when reading a file sequentially o 3200 3200 4000 4000 4001 4001} -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } file delete -force $vfs unset -nocomplain result expected fp vfs file data } @@ -95,13 +95,13 @@ tcltest::test cookfsReaderChannel-3 {position when reading a file sequentially o tcltest::test cookfsReaderChannel-4 {position when reading a file randomly over several pages} -setup { set vfs [tcltest::makeFile {} cookfs.cfs] # page size is 899 bytes - vfs::cookfs::Mount -compression none -pagesize 899 -smallfilesize 1 -smallfilebuffer 0 $vfs $vfs + cookfs::Mount -compression none -pagesize 899 -smallfilesize 1 -smallfilebuffer 0 $vfs $vfs set data "[string repeat "TEST" 1000]\n" # 4x1000+ = 4001 bytes set file [tcltest::makeFile $data test $vfs] - vfs::unmount $vfs + cookfs::Unmount $vfs } -body { - vfs::cookfs::Mount -readonly $vfs $vfs + cookfs::Mount -readonly $vfs $vfs set result [list] set fp [open $file r] fconfigure $fp -translation binary -encoding binary @@ -129,7 +129,7 @@ tcltest::test cookfsReaderChannel-4 {position when reading a file randomly over lappend result [list $offset $size [expr { $x eq [string range $data $offset [expr { $offset+$size }]-1] }] [tell $fp] $expected] } close $fp - vfs::unmount $vfs + cookfs::Unmount $vfs join $result \n } -result {0 1 1 1 1 0 10 1 10 10 @@ -146,7 +146,7 @@ tcltest::test cookfsReaderChannel-4 {position when reading a file randomly over 4000 1 1 4001 4001 4000 10 1 4001 4001 4000 1500 1 4001 4001} -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } file delete -force $vfs unset vfs file unset -nocomplain result expected fp x data @@ -155,14 +155,14 @@ tcltest::test cookfsReaderChannel-4 {position when reading a file randomly over tcltest::test cookfsReaderChannel-5.1 {readable fileevent works for file in pages} -setup { set vfs [tcltest::makeFile {} cookfs.cfs] - vfs::cookfs::Mount $vfs $vfs + cookfs::Mount $vfs $vfs set data "[string repeat "TEST" 1000]\n" set file [tcltest::makeFile $data test $vfs] - vfs::unmount $vfs + cookfs::Unmount $vfs } -body { set ::result "" set ::wait 0 - vfs::cookfs::Mount -readonly $vfs $vfs + cookfs::Mount -readonly $vfs $vfs set fp [open $file rb] fileevent $fp readable [list apply {{ chan } { if {[eof $chan]} { @@ -175,11 +175,11 @@ tcltest::test cookfsReaderChannel-5.1 {readable fileevent works for file in page vwait ::wait catch { after cancel $timer } close $fp - vfs::unmount $vfs + cookfs::Unmount $vfs list [string equal $::result $::data] $::wait } -result [list 1 "eof"] -cleanup { catch { close $fp } - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } file delete -force $vfs catch { after cancel $timer } unset -nocomplain vfs data file result fp chan timer wait @@ -194,7 +194,7 @@ tcltest::test cookfsReaderChannel-5.2 {readable fileevent works for file in smal # 4x1000+ = 4001 bytes set data "[string repeat "TEST" 1000]\n" # ensure that files below 64kb will be stored in the smallfilebuffer - vfs::cookfs::Mount $vfs $vfs -smallfilesize 65536 -smallfilebuffer 65536 + cookfs::Mount $vfs $vfs -smallfilesize 65536 -smallfilebuffer 65536 set fp [open $file wb] puts -nonewline $fp $data close $fp @@ -210,11 +210,11 @@ tcltest::test cookfsReaderChannel-5.2 {readable fileevent works for file in smal vwait ::wait catch { after cancel $timer } close $fp - vfs::unmount $vfs + cookfs::Unmount $vfs list [string equal $::result $::data] $::wait } -result [list 1 "eof"] -cleanup { catch { close $fp } - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } file delete -force $vfs catch { after cancel $timer } unset -nocomplain vfs data file result fp chan timer wait @@ -222,20 +222,20 @@ tcltest::test cookfsReaderChannel-5.2 {readable fileevent works for file in smal tcltest::test cookfsReaderChannel-6.1 {channel options for file in pages} -setup { set vfs [tcltest::makeFile {} cookfs.cfs] - vfs::cookfs::Mount $vfs $vfs + cookfs::Mount $vfs $vfs set file [tcltest::makeFile {} test $vfs] - vfs::unmount $vfs + cookfs::Unmount $vfs } -body { # get default channel options for native filesystem, don't use "rb" here set fp [open $vfs r] set expected [fconfigure $fp] close $fp - vfs::cookfs::Mount -readonly $vfs $vfs + cookfs::Mount -readonly $vfs $vfs # don't use "rb" here set fp [open $file r] set actual [fconfigure $fp] close $fp - vfs::unmount $vfs + cookfs::Unmount $vfs set result [list] foreach opt {-translation -encoding -eofchar} { if { [dict get $expected $opt] eq [dict get $actual $opt] } { @@ -247,7 +247,7 @@ tcltest::test cookfsReaderChannel-6.1 {channel options for file in pages} -setup set result } -result [list -translation ok -encoding ok -eofchar ok] -cleanup { catch { close $fp } - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } file delete -force $vfs unset -nocomplain vfs file fp expected result opt actual } @@ -262,7 +262,7 @@ tcltest::test cookfsReaderChannel-6.2 {channel options for file in smallfilebuff close $fp set data "123" # ensure that files below 64kb will be stored in the smallfilebuffer - vfs::cookfs::Mount $vfs $vfs -smallfilesize 65536 -smallfilebuffer 65536 + cookfs::Mount $vfs $vfs -smallfilesize 65536 -smallfilebuffer 65536 set fp [open $file wb] puts -nonewline $fp $data close $fp @@ -270,7 +270,7 @@ tcltest::test cookfsReaderChannel-6.2 {channel options for file in smallfilebuff set fp [open $file r] set actual [fconfigure $fp] close $fp - vfs::unmount $vfs + cookfs::Unmount $vfs set result [list] foreach opt {-translation -encoding -eofchar} { if { [dict get $expected $opt] eq [dict get $actual $opt] } { @@ -282,7 +282,7 @@ tcltest::test cookfsReaderChannel-6.2 {channel options for file in smallfilebuff set result } -result [list -translation ok -encoding ok -eofchar ok] -cleanup { catch { close $fp } - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } file delete -force $vfs unset -nocomplain vfs file fp data expected result opt actual } diff --git a/tests/vfs.test b/tests/vfs.test index a57dfda..2853887 100644 --- a/tests/vfs.test +++ b/tests/vfs.test @@ -1,21 +1,21 @@ tcltest::test cookfsVfs-1.1.1 "Mount empty filename (unix)" -constraints unix -setup { } -body { - vfs::cookfs::Mount "" "" + cookfs::Mount "" "" } -cleanup { } -returnCodes {error} -match glob -result {Unable to create Cookfs object: couldn't open "*": illegal operation on a directory} tcltest::test cookfsVfs-1.1.2 "Mount empty filename (windows)" -constraints win -setup { } -body { - vfs::cookfs::Mount "" "" + cookfs::Mount "" "" } -cleanup { } -returnCodes {error} -match glob -result {Unable to create Cookfs object: couldn't open "*": permission denied} tcltest::test cookfsVfs-1.2 "Mount non-existant file as read-write" -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { - set fsid [vfs::cookfs::Mount $file $file] - vfs::unmount $file + set fsid [cookfs::Mount $file $file] + cookfs::Unmount $file set fsid } -cleanup { tcltest::removeFile $file @@ -25,9 +25,9 @@ tcltest::test cookfsVfs-1.2 "Mount non-existant file as read-write" -setup { tcltest::test cookfsVfs-1.3 "Mount non-existant file as read-only" -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { - vfs::cookfs::Mount -readonly $file $file + cookfs::Mount -readonly $file $file } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file } -returnCodes {error} -result {Unable to create Cookfs object: index not found} @@ -35,22 +35,22 @@ tcltest::test cookfsVfs-1.3 "Mount non-existant file as read-only" -setup { tcltest::test cookfsVfs-1.4 "Remounting archive" -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { - vfs::cookfs::Mount $file $file + cookfs::Mount $file $file set fh [open [file join $file testfile] w] fconfigure $fh -translation binary puts $fh TEST close $fh - vfs::unmount $file + cookfs::Unmount $file - vfs::cookfs::Mount $file $file + cookfs::Mount $file $file file exists [file join $file testfile] } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fh } -returnCodes {ok} -result 1 -tcltest::test cookfsVfs-1.5 "Remounting archive using -pagesobject" -setup { +tcltest::test cookfsVfs-1.5 "Remounting archive using -pagesobject" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { vfs::cookfs::Mount $file $file @@ -69,7 +69,7 @@ tcltest::test cookfsVfs-1.5 "Remounting archive using -pagesobject" -setup { unset -nocomplain file fh p h } -returnCodes {ok} -result 1 -tcltest::test cookfsVfs-1.6 "Remounting archive using -fsindexobject" -setup { +tcltest::test cookfsVfs-1.6 "Remounting archive using -fsindexobject" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { vfs::cookfs::Mount $file $file @@ -92,25 +92,25 @@ tcltest::test cookfsVfs-1.6 "Remounting archive using -fsindexobject" -setup { tcltest::test cookfsVfs-1.7 "Setting metadata on mount" -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { - vfs::cookfs::Mount $file $file + cookfs::Mount $file $file set fh [open [file join $file testfile] w] fconfigure $fh -translation binary puts $fh TEST close $fh - vfs::unmount $file + cookfs::Unmount $file - set h [vfs::cookfs::Mount $file $file -setmetadata {test1 1 test2 2}] - vfs::unmount $file + set h [cookfs::Mount $file $file -setmetadata {test1 1 test2 2}] + cookfs::Unmount $file - set h [vfs::cookfs::Mount $file $file] + set h [cookfs::Mount $file $file] format %s,%s [$h getmetadata test1] [$h getmetadata test2] } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fh h } -returnCodes {ok} -result 1,2 -tcltest::test cookfsVfs-1.8.1 "Mounting as volume, unmount with vfs::unmount" -setup { +tcltest::test cookfsVfs-1.8.1 "Mounting as volume, unmount with vfs::unmount" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { vfs::cookfs::Mount $file $file @@ -136,26 +136,26 @@ tcltest::test cookfsVfs-1.8.1 "Mounting as volume, unmount with vfs::unmount" -s tcltest::test cookfsVfs-1.8.2 "Mounting as volume, unmount with cookfs::Unmount" -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { - vfs::cookfs::Mount $file $file + cookfs::Mount $file $file set fh [open [file join $file testfile] w] fconfigure $fh -translation binary puts $fh TEST close $fh - vfs::unmount $file + cookfs::Unmount $file - set h [vfs::cookfs::Mount $file test:/ -volume] + set h [cookfs::Mount $file test:/ -volume] set result [expr {([lsearch -exact [file volumes] test:/]>=0)?1:0}] cookfs::Unmount test:/ set result } -cleanup { - catch {vfs::unmount $file} - catch {vfs::unmount test:/} + catch {cookfs::Unmount $file} + catch {cookfs::Unmount test:/} tcltest::removeFile $file unset -nocomplain file fh h result } -returnCodes {ok} -result 1 -tcltest::test cookfsVfs-1.9 "Test storing same files" -setup { +tcltest::test cookfsVfs-1.9 "Test storing same files" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { vfs::cookfs::Mount $file $file -smallfilesize 40960 @@ -193,11 +193,11 @@ tcltest::test cookfsVfs-2.1 "Test compressing entire directory structure" -setup makeSimpleTree $dir set file [tcltest::makeFile {} cookfs.cfs] } -body { - vfs::cookfs::Mount $file $file + cookfs::Mount $file $file file copy -force $dir [file join $file vfs] testIfEqual $dir [file join $file vfs] } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeDirectory $dir tcltest::removeFile $file unset -nocomplain file dir @@ -208,13 +208,13 @@ tcltest::test cookfsVfs-2.2 "Test compressing entire directory structure after r makeSimpleTree $dir set file [tcltest::makeFile {} cookfs.cfs] } -body { - vfs::cookfs::Mount $file $file + cookfs::Mount $file $file file copy -force $dir [file join $file vfs] - vfs::unmount $file - vfs::cookfs::Mount $file $file + cookfs::Unmount $file + cookfs::Mount $file $file testIfEqual $dir [file join $file vfs] } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeDirectory $dir tcltest::removeFile $file unset -nocomplain file dir @@ -223,77 +223,77 @@ tcltest::test cookfsVfs-2.2 "Test compressing entire directory structure after r tcltest::test cookfsVfs-2.3 "Test correct storing of empty files or new directory as only change in existing cookfs" -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] set fh [open $file/file1 w] fconfigure $fh -translation binary puts $fh [string repeat TEST 1024] close $fh - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] # create 2 files so length of new index is not smaller than previously close [open $file/file2 w] close [open $file/file34 w] - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] if {![file exists $file/file2]} { error "Unable to find file2 in archive" } # create 2 directories so length of new index is not smaller than previously file mkdir $file/dir1 file mkdir $file/dir23 - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] if {![file exists $file/dir1]} { error "Unable to find dir1 in archive" } } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh } -returnCodes {ok} tcltest::test cookfsVfs-3.1 "Test creating files in non-existant directory in VFS" -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { close [open $file/somedir/file w] } -cleanup { - vfs::unmount $file + cookfs::Unmount $file tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {error} -match glob -result "*no such file or directory*" tcltest::test cookfsVfs-3.2 "Test creating files in file in VFS" -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { close [open $file/file w] close [open $file/file/otherfile w] } -cleanup { - vfs::unmount $file + cookfs::Unmount $file tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {error} -match glob -result "*not a directory*" tcltest::test cookfsVfs-3.3 "Test creating directories in file in VFS" -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { close [open $file/file w] file mkdir $file/file/somedir } -cleanup { - vfs::unmount $file + cookfs::Unmount $file tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {error} -match glob -result "*file already exists*" tcltest::test cookfsVfs-3.4 "Test creating directories and files" -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { file mkdir $file/dir1 file mkdir $file/dir2 @@ -301,14 +301,14 @@ tcltest::test cookfsVfs-3.4 "Test creating directories and files" -setup { close [open $file/file2 w] close [open $file/dir2/file4 w] close [open $file/dir2/dir3/file5 w] - vfs::unmount $file - set fsid [vfs::cookfs::Mount $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount $file $file] concat \ [lsort [glob -tails -directory $file * */* */*/*]] \ [lsort [glob -tails -directory $file -type d -nocomplain * */* */*/*]] \ [lsort [glob -tails -directory $file -type f -nocomplain * */* */*/*]] } -cleanup { - vfs::unmount $file + cookfs::Unmount $file tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {ok} -result {dir1 dir2 dir2/dir3 dir2/dir3/file5 dir2/file4 file2 dir1 dir2 dir2/dir3 dir2/dir3/file5 dir2/file4 file2} @@ -316,22 +316,22 @@ tcltest::test cookfsVfs-3.4 "Test creating directories and files" -setup { tcltest::test cookfsVfs-4.2 "Test add-aside feature using fsid aside command" -constraints cookfsAside -setup { set file [tcltest::makeFile {} cookfs.cfs] set file2 [tcltest::makeFile {} cookfs2.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] close [open $file/file1 w] file mkdir $file/dir1 - vfs::unmount $file + cookfs::Unmount $file } -body { - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] $fsid aside $file2 file mkdir $file/dir2 close [open $file/file2 w] - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] $fsid aside $file2 lsort [glob -directory $file -tails *] } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file tcltest::removeFile $file2 unset -nocomplain file file2 fsid @@ -339,94 +339,94 @@ tcltest::test cookfsVfs-4.2 "Test add-aside feature using fsid aside command" -c tcltest::test cookfsVfs-4.4 "Test write to memory feature using fsid writetomemory command" -constraints cookfsAside -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] close [open $file/file1 w] file mkdir $file/dir1 - vfs::unmount $file + cookfs::Unmount $file } -body { - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] $fsid writetomemory file mkdir $file/dir2 close [open $file/file2 w] - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] lsort [glob -directory $file -tails *] } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {ok} -result {dir1 file1} tcltest::test cookfsVfs-5.1 "Test getting metadata using fsid getmetadata command without default value" -constraints cookfsMetadata -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] $fsid getmetadata nonexistant } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {error} -result {Parameter not defined} tcltest::test cookfsVfs-5.2 "Test getting metadata using fsid getmetadata command with default value" -constraints cookfsMetadata -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] $fsid getmetadata nonexistant 12 } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {ok} -result {12} tcltest::test cookfsVfs-5.3 "Test setting metadata using fsid setmetadata command" -constraints cookfsMetadata -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { $fsid setmetadata somename othervalue } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {ok} tcltest::test cookfsVfs-5.4 "Test setting metadata in a read-only mount" -constraints cookfsMetadata -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] $fsid setmetadata somename othervalue } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {error} -result {Archive is read-only} tcltest::test cookfsVfs-5.5 "Test setting and getting metadata" -constraints cookfsMetadata -setup { set file [tcltest::makeFile {} cookfs.cfs] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] } -body { $fsid setmetadata somename othervalue - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount -readonly $file $file] + set fsid [cookfs::Mount -readonly $file $file] $fsid getmetadata somename } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid } -returnCodes {ok} -result {othervalue} -tcltest::test cookfsVfs-6.1 "Test crc32 based VFS and page handling" -constraints cookfsMetadata -setup { +tcltest::test cookfsVfs-6.1 "Test crc32 based VFS and page handling" -constraints {cookfsMetadata enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] } -body { vfs::cookfs::Mount -pagehash crc32 $file $file @@ -457,7 +457,7 @@ tcltest::test cookfsVfs-7.1 "Test filesize command" -setup { puts -nonewline $fh [string repeat "TEST" 1024] close $fh } -body { - set fsid [vfs::cookfs::Mount -smallfilesize 8192 -compression none $file $file] + set fsid [cookfs::Mount -smallfilesize 8192 -compression none $file $file] set fh [open [file join $file testfile1] w] fconfigure $fh -translation binary puts -nonewline $fh [string repeat "Test0001" 4096] @@ -468,7 +468,7 @@ tcltest::test cookfsVfs-7.1 "Test filesize command" -setup { close $fh $fsid filesize } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fh fsid } -returnCodes {ok} -result 69649 @@ -479,7 +479,7 @@ tcltest::test cookfsVfs-7.2 "Test smallfilebuffersize command" -setup { set fh [open $file w] close $fh } -body { - set fsid [vfs::cookfs::Mount -smallfilesize 8192 -compression none $file $file] + set fsid [cookfs::Mount -smallfilesize 8192 -compression none $file $file] set fh [open [file join $file testfile1] w] fconfigure $fh -translation binary puts -nonewline $fh [string repeat "Test0001" 4096] @@ -494,7 +494,7 @@ tcltest::test cookfsVfs-7.2 "Test smallfilebuffersize command" -setup { close $fh $fsid smallfilebuffersize } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh } -returnCodes {ok} -result 1024 @@ -505,23 +505,23 @@ tcltest::test cookfsVfs-8.1 "Test modifying file mtime" -setup { set fh [open $file w] close $fh } -body { - set fsid [vfs::cookfs::Mount -compression none $file $file] + set fsid [cookfs::Mount -compression none $file $file] set fh [open [file join $file testfile1] w] fconfigure $fh -translation binary puts -nonewline $fh [string repeat "Test0001" 4096] close $fh file mtime [file join $file testfile1] 1 - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] if {[file mtime [file join $file testfile1]] != "1"} { error "Invalid mtime after first pass" } file mtime [file join $file testfile1] 1342177280 - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] file mtime [file join $file testfile1] } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh } -returnCodes {ok} -result 1342177280 @@ -532,21 +532,21 @@ tcltest::test cookfsVfs-9.1 "Test deleting files" -setup { set fh [open $file w] close $fh } -body { - set fsid [vfs::cookfs::Mount -compression none $file $file] + set fsid [cookfs::Mount -compression none $file $file] close [open [file join $file testfile1] w] close [open [file join $file testfile2] w] file mkdir [file join $file testdir1] file mkdir [file join $file testdir2] close [open [file join $file testdir2/testfile3] w] close [open [file join $file testdir2/testfile4] w] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] file delete -force [file join $file testfile1] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] join [lsort [glob -tails -directory $file * */*]] , } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh } -returnCodes {ok} -result {testdir1,testdir2,testdir2/testfile3,testdir2/testfile4,testfile2} @@ -557,21 +557,21 @@ tcltest::test cookfsVfs-9.2 "Test deleting empty directories" -setup { set fh [open $file w] close $fh } -body { - set fsid [vfs::cookfs::Mount -compression none $file $file] + set fsid [cookfs::Mount -compression none $file $file] close [open [file join $file testfile1] w] close [open [file join $file testfile2] w] file mkdir [file join $file testdir1] file mkdir [file join $file testdir2] close [open [file join $file testdir2 testfile3] w] close [open [file join $file testdir2 testfile4] w] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] file delete -force [file join $file testdir1] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] join [lsort [glob -tails -directory $file * */*]] , } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh } -returnCodes {ok} -result {testdir2,testdir2/testfile3,testdir2/testfile4,testfile1,testfile2} @@ -582,21 +582,21 @@ tcltest::test cookfsVfs-9.3 "Test deleting non-empty directories" -setup { set fh [open $file w] close $fh } -body { - set fsid [vfs::cookfs::Mount -compression none $file $file] + set fsid [cookfs::Mount -compression none $file $file] close [open [file join $file testfile1] w] close [open [file join $file testfile2] w] file mkdir [file join $file testdir1] file mkdir [file join $file testdir2] close [open [file join $file testdir2 estfile3] w] close [open [file join $file testdir2 testfile4] w] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] file delete -force [file join $file testdir2] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] join [lsort [glob -tails -directory $file * */*]] , } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh } -returnCodes {ok} -result {testdir1,testfile1,testfile2} @@ -607,7 +607,7 @@ tcltest::test cookfsVfs-9.4 "Test deleting non-empty directories with complex st set fh [open $file w] close $fh } -body { - set fsid [vfs::cookfs::Mount -compression none $file $file] + set fsid [cookfs::Mount -compression none $file $file] close [open [file join $file testfile1] w] close [open [file join $file testfile2] w] file mkdir [file join $file testdir1] @@ -618,25 +618,25 @@ tcltest::test cookfsVfs-9.4 "Test deleting non-empty directories with complex st close [open [file join $file testdir2 testfile4] w] close [open [file join $file testdir2 testdir3 testfile5] w] close [open [file join $file testdir2 testdir3 testfile6] w] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] file delete -force [file join $file testdir2] - catch {vfs::unmount $file} - set fsid [vfs::cookfs::Mount -compression none $file $file] + cookfs::Unmount $file + set fsid [cookfs::Mount -compression none $file $file] join [lsort [glob -tails -directory $file * */*]] , } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh } -returnCodes {ok} -result {testdir1,testfile1,testfile2} -tcltest::test cookfsVfs-10.1 "Test changing compression without remounting" -setup { +tcltest::test cookfsVfs-10.1 "Test changing compression without remounting" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file set fh [open $file w] close $fh } -body { - set fsid [vfs::cookfs::Mount $file $file -compression zlib -smallfilesize 32768 \ + set fsid [cookfs::Mount $file $file -compression zlib -smallfilesize 32768 \ -compresscommand testcompressraw -decompresscommand testdecompressraw -alwayscompress] if {[$fsid compression] != "zlib"} { error "Getting compression does not return \"zlib\"" @@ -661,12 +661,12 @@ tcltest::test cookfsVfs-10.1 "Test changing compression without remounting" -set if {[$fsid compression] != "custom"} { error "Getting compression does not return \"custom\"" } - vfs::unmount $file + cookfs::Unmount $file - set fsid [vfs::cookfs::Mount $file $file -readonly \ + set fsid [cookfs::Mount $file $file -readonly \ -compresscommand testcompressraw -decompresscommand testdecompressraw -alwayscompress] set idx [[$fsid getpages] index] - vfs::unmount $file + cookfs::Unmount $file set fh [open $file r] fconfigure $fh -translation binary @@ -685,7 +685,7 @@ tcltest::test cookfsVfs-10.1 "Test changing compression without remounting" -set error "Index not found" } } -cleanup { - catch {vfs::unmount $file} + catch {cookfs::Unmount $file} tcltest::removeFile $file unset -nocomplain file fsid fh fc idx testrawcleanup @@ -698,7 +698,7 @@ tcltest::test cookfsVfs-11.1 "Test unmount using fsid" -setup { } -body { set result [list] lappend result [file type $file] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] lappend result [file type $file] # ensure that mount handler command exists lappend result [llength [info commands $fsid]] @@ -707,7 +707,7 @@ tcltest::test cookfsVfs-11.1 "Test unmount using fsid" -setup { # ensure that mount handler command deleted lappend result [llength [info commands $fsid]] } -cleanup { - catch { vfs::unmount $file } + catch { cookfs::Unmount $file } tcltest::removeFile $file unset -nocomplain file fsid result } -result {file directory 1 file 0} @@ -719,7 +719,7 @@ tcltest::test cookfsVfs-11.2 "Test unmount using mount point" -setup { } -body { set result [list] lappend result [file type $file] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] lappend result [file type $file] # ensure that mount handler command exists lappend result [llength [info commands $fsid]] @@ -728,7 +728,7 @@ tcltest::test cookfsVfs-11.2 "Test unmount using mount point" -setup { # ensure that mount handler command deleted lappend result [llength [info commands $fsid]] } -cleanup { - catch { vfs::unmount $file } + catch { cookfs::Unmount $file } tcltest::removeFile $file unset -nocomplain file fsid fh result } -result {file directory 1 file 0} @@ -740,7 +740,7 @@ tcltest::test cookfsVfs-11.3 "Test unmount using mount point (relative)" -setup } -body { set result [list] lappend result [file type $file] - set fsid [vfs::cookfs::Mount $file $file] + set fsid [cookfs::Mount $file $file] lappend result [file type $file] # ensure that mount handler command exists lappend result [llength [info commands $fsid]] @@ -749,12 +749,12 @@ tcltest::test cookfsVfs-11.3 "Test unmount using mount point (relative)" -setup # ensure that mount handler command deleted lappend result [llength [info commands $fsid]] } -cleanup { - catch { vfs::unmount $file } + catch { cookfs::Unmount $file } tcltest::removeFile $file unset -nocomplain file fsid result } -result {file directory 1 file 0} -tcltest::test cookfsVfs-11.4 "Test unmount using vfs::unmount" -constraints packageTclvfs -setup { +tcltest::test cookfsVfs-11.4 "Test unmount using vfs::unmount" -constraints {packageTclvfs enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -775,7 +775,7 @@ tcltest::test cookfsVfs-11.4 "Test unmount using vfs::unmount" -constraints pack unset -nocomplain file fsid result } -result {file directory 1 file 0} -tcltest::test cookfsVfs-12.1 "Test registration in tclvfs, should be registered by default" -constraints packageTclvfs -setup { +tcltest::test cookfsVfs-12.1 "Test registration in tclvfs, should be registered by default" -constraints {packageTclvfs enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -799,7 +799,7 @@ tcltest::test cookfsVfs-12.1 "Test registration in tclvfs, should be registered } -result {file directory 1 file 0} # Run this test with c-vfs only, as tcl-vfs will not work if cookfs is not registered with tclvfs. -tcltest::test cookfsVfs-12.2 "Test registration in tclvfs, should not be registered due to -noregister" -constraints { enabledCVfs packageTclvfs } -setup { +tcltest::test cookfsVfs-12.2 "Test registration in tclvfs, should not be registered due to -noregister" -constraints { enabledCVfs packageTclvfs enabledTclCmds } -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -826,7 +826,7 @@ tcltest::test cookfsVfs-12.2 "Test registration in tclvfs, should not be registe unset -nocomplain file fsid result } -result {file directory 1 1 1 directory 0 file 0} -tcltest::test cookfsVfs-12.3 "Test that cookfs::Unmount invoked with fsid unregister cookfs in tclvfs" -constraints packageTclvfs -setup { +tcltest::test cookfsVfs-12.3 "Test that cookfs::Unmount invoked with fsid unregister cookfs in tclvfs" -constraints { packageTclvfs enabledTclCmds } -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -856,7 +856,7 @@ tcltest::test cookfsVfs-12.3 "Test that cookfs::Unmount invoked with fsid unregi unset -nocomplain file fsid result err } -match glob -result {file directory 1 0 file 0 1 {can't read "_unmountCmd(*)": no such element in array} file 0} -tcltest::test cookfsVfs-12.4 "Test that cookfs::Unmount invoked with mount path unregister cookfs in tclvfs" -constraints packageTclvfs -setup { +tcltest::test cookfsVfs-12.4 "Test that cookfs::Unmount invoked with mount path unregister cookfs in tclvfs" -constraints { packageTclvfs enabledTclCmds } -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -884,7 +884,7 @@ tcltest::test cookfsVfs-12.4 "Test that cookfs::Unmount invoked with mount path unset -nocomplain file fsid result err } -match glob -result {file directory 1 0 file 0 1 {can't read "_unmountCmd(*)": no such element in array} file} -tcltest::test cookfsVfs-13.1 "Test -bootstrap option for cookfs::Mount, when opening new archive" -setup { +tcltest::test cookfsVfs-13.1 "Test -bootstrap option for cookfs::Mount, when opening new archive" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -900,7 +900,7 @@ tcltest::test cookfsVfs-13.1 "Test -bootstrap option for cookfs::Mount, when ope unset -nocomplain file fsid bootstrap } -result 1 -tcltest::test cookfsVfs-13.2 "Test -bootstrap option for cookfs::Mount is ignored, when opening existing archive" -setup { +tcltest::test cookfsVfs-13.2 "Test -bootstrap option for cookfs::Mount is ignored, when opening existing archive" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -916,7 +916,7 @@ tcltest::test cookfsVfs-13.2 "Test -bootstrap option for cookfs::Mount is ignore unset -nocomplain file fsid bootstrap } -result 1 -tcltest::test cookfsVfs-13.3 "Test -bootstrap option for cookfs::Mount, ignore empty bootstrap" -setup { +tcltest::test cookfsVfs-13.3 "Test -bootstrap option for cookfs::Mount, ignore empty bootstrap" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -929,7 +929,7 @@ tcltest::test cookfsVfs-13.3 "Test -bootstrap option for cookfs::Mount, ignore e unset -nocomplain file fsid } -result 0 -tcltest::test cookfsVfs-14.1 "Test -pagehash option for cookfs::Mount, when opening new archive (md5)" -constraints enabledCPages -setup { +tcltest::test cookfsVfs-14.1 "Test -pagehash option for cookfs::Mount, when opening new archive (md5)" -constraints { enabledCPages enabledTclCmds } -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -945,7 +945,7 @@ tcltest::test cookfsVfs-14.1 "Test -pagehash option for cookfs::Mount, when open unset -nocomplain file fsid hash result } -result {1 1} -tcltest::test cookfsVfs-14.2 "Test -pagehash option for cookfs::Mount, when opening new archive (crc32)" -setup { +tcltest::test cookfsVfs-14.2 "Test -pagehash option for cookfs::Mount, when opening new archive (crc32)" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -961,7 +961,7 @@ tcltest::test cookfsVfs-14.2 "Test -pagehash option for cookfs::Mount, when open unset -nocomplain file fsid hash result } -result {1 1} -tcltest::test cookfsVfs-14.3 "Test -pagehash option for cookfs::Mount, when reopening (md5)" -constraints enabledCPages -setup { +tcltest::test cookfsVfs-14.3 "Test -pagehash option for cookfs::Mount, when reopening (md5)" -constraints { enabledCPages enabledTclCmds } -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -981,7 +981,7 @@ tcltest::test cookfsVfs-14.3 "Test -pagehash option for cookfs::Mount, when reop unset -nocomplain file fsid hash result } -result {1 1} -tcltest::test cookfsVfs-14.4 "Test -pagehash option for cookfs::Mount, when reopening (crc32)" -setup { +tcltest::test cookfsVfs-14.4 "Test -pagehash option for cookfs::Mount, when reopening (crc32)" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -1002,7 +1002,7 @@ tcltest::test cookfsVfs-14.4 "Test -pagehash option for cookfs::Mount, when reop } -result {1 1} -tcltest::test cookfsVfs-14.5 "Test -pagehash option for cookfs::Mount is ignored, when opening existing archive" -setup { +tcltest::test cookfsVfs-14.5 "Test -pagehash option for cookfs::Mount is ignored, when opening existing archive" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -1024,7 +1024,7 @@ tcltest::test cookfsVfs-14.5 "Test -pagehash option for cookfs::Mount is ignored # Here we just check if " getmetadata cookfs.pagehash" ends with an error. # Actual values are not interested. -tcltest::test cookfsVfs-14.6 "Test that cookfs.pagehash metadata exists by default" -setup { +tcltest::test cookfsVfs-14.6 "Test that cookfs.pagehash metadata exists by default" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -1043,7 +1043,7 @@ tcltest::test cookfsVfs-14.6 "Test that cookfs.pagehash metadata exists by defau unset -nocomplain file fsid result } -match glob -result {* *} -tcltest::test cookfsVfs-14.7 "Test that cookfs.pagehash metadata matches actual pages hash" -setup { +tcltest::test cookfsVfs-14.7 "Test that cookfs.pagehash metadata matches actual pages hash" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} pages.cfs] # make sure no additional data is written to file close [open $file w] @@ -1068,14 +1068,14 @@ tcltest::test cookfsVfs-14.8 "Test unknown hash value" -setup { close [open $file w] } -body { set result [list] - set fsid [vfs::cookfs::Mount -pagehash foo $file $file] + set fsid [cookfs::Mount -pagehash foo $file $file] } -cleanup { - catch { vfs::unmount $file } + catch { cookfs::Unmount $file } tcltest::removeFile $file unset -nocomplain file fsid result } -returnCodes error -result {bad hash "foo": must be md5 or crc32} -tcltest::test cookfsVfs-15.1 "Test optimizelist with empty base" -setup { +tcltest::test cookfsVfs-15.1 "Test optimizelist with empty base" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] set fsid [vfs::cookfs::Mount $file $file -compression none \ -smallfilesize 0x10 -smallfilebuffer 0x30 -pagesize 0x10] @@ -1094,7 +1094,7 @@ tcltest::test cookfsVfs-15.1 "Test optimizelist with empty base" -setup { unset -nocomplain file fsid h files } -result {} -tcltest::test cookfsVfs-15.2 "Test optimizelist with non-empty base" -setup { +tcltest::test cookfsVfs-15.2 "Test optimizelist with non-empty base" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] set fsid [vfs::cookfs::Mount $file $file -compression none \ -smallfilesize 0x10 -smallfilebuffer 0x30 -pagesize 0x10] diff --git a/tests/vfsCache.test b/tests/vfsCache.test index 864a5d8..6098700 100644 --- a/tests/vfsCache.test +++ b/tests/vfsCache.test @@ -1,5 +1,5 @@ -tcltest::test cookfsVfsCache-1 "Test cache eviction based on weight and age" -setup { +tcltest::test cookfsVfsCache-1 "Test cache eviction based on weight and age" -constraints {enabledTclCmds} -setup { set file [tcltest::makeFile {} cookfs.cfs] vfs::cookfs::Mount $file $file -smallfilesize 50 -smallfilebuffer 5 -pagesize 150 tcltest::makeFile [string repeat 1 100] test1 $file diff --git a/tests/writer.test b/tests/writer.test index 9fdc0e9..e462c6e 100644 --- a/tests/writer.test +++ b/tests/writer.test @@ -5,7 +5,7 @@ tcltest::test cookfsWriter-1.1 "Add small files" -setup { set datas [randomDatas 3 1024] set file1 [tcltest::makeBinFile [lindex $datas 0] file1] set file2 [tcltest::makeBinFile [lindex $datas 1] file2] - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 4096 -smallfilesize 4096 -smallfilebuffer 16384 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 4096 -smallfilesize 4096 -smallfilebuffer 16384 -compression none] set channel [open $file1 rb] $h writeFiles file1 channel $channel "" file2 file $file2 "" file3 data [lindex $datas 2] "" close $channel @@ -15,17 +15,17 @@ tcltest::test cookfsWriter-1.1 "Add small files" -setup { lappend result "file2 [string equal [tcltest::viewBinFile $vfs/file2] [lindex $datas 1]]" lappend result "file3 [string equal [tcltest::viewBinFile $vfs/file3] [lindex $datas 2]]" # flush the files to pages - vfs::unmount $vfs - set h [vfs::cookfs::Mount -readonly $vfs $vfs] + cookfs::Unmount $vfs + set h [cookfs::Mount -readonly $vfs $vfs] # read the files again lappend result "file1 [string equal [tcltest::viewBinFile $vfs/file1] [lindex $datas 0]]" lappend result "file2 [string equal [tcltest::viewBinFile $vfs/file2] [lindex $datas 1]]" lappend result "file3 [string equal [tcltest::viewBinFile $vfs/file3] [lindex $datas 2]]" - vfs::unmount $vfs + cookfs::Unmount $vfs lappend result {} join $result \n } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } catch { close $channel } tcltest::removeFile $vfs tcltest::removeFile $file1 @@ -46,7 +46,7 @@ tcltest::test cookfsWriter-1.2 "Add big files" -setup { set datas [randomDatas 3 1024] set file1 [tcltest::makeBinFile [lindex $datas 0] file1] set file2 [tcltest::makeBinFile [lindex $datas 1] file2] - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 512 -smallfilesize 512 -smallfilebuffer 16384 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 512 -smallfilesize 512 -smallfilebuffer 16384 -compression none] set channel [open $file1 rb] $h writeFiles file1 channel $channel "" file2 file $file2 "" file3 data [lindex $datas 2] "" close $channel @@ -56,17 +56,17 @@ tcltest::test cookfsWriter-1.2 "Add big files" -setup { lappend result "file2 [string equal [tcltest::viewBinFile $vfs/file2] [lindex $datas 1]]" lappend result "file3 [string equal [tcltest::viewBinFile $vfs/file3] [lindex $datas 2]]" # flush the files to pages - vfs::unmount $vfs - set h [vfs::cookfs::Mount -readonly $vfs $vfs] + cookfs::Unmount $vfs + set h [cookfs::Mount -readonly $vfs $vfs] # read the files again lappend result "file1 [string equal [tcltest::viewBinFile $vfs/file1] [lindex $datas 0]]" lappend result "file2 [string equal [tcltest::viewBinFile $vfs/file2] [lindex $datas 1]]" lappend result "file3 [string equal [tcltest::viewBinFile $vfs/file3] [lindex $datas 2]]" - vfs::unmount $vfs + cookfs::Unmount $vfs lappend result {} join $result \n } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } tcltest::removeFile $vfs tcltest::removeFile $file1 tcltest::removeFile $file2 @@ -83,10 +83,10 @@ file3 1 tcltest::test cookfsWriter-2.1 "Error while adding files without parent directory" -setup { set vfs [tcltest::makeFile {} pages.cfs] } -body { - set h [vfs::cookfs::Mount $vfs $vfs -compression none] + set h [cookfs::Mount $vfs $vfs -compression none] $h writeFiles file1 data x "" somedirectory/file2 data y "" } -cleanup { - vfs::unmount $vfs + cookfs::Unmount $vfs tcltest::removeFile $vfs unset -nocomplain vfs h } -returnCodes error -result {unable to add "somedirectory/file2": Unable to create entry} @@ -95,24 +95,24 @@ tcltest::test cookfsWriter-3.1 "Add the same file while previous file is in smal set vfs [tcltest::makeFile {} pages.cfs] } -body { set datas [randomDatas 3 1024] - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 4096 -smallfilesize 4096 -smallfilebuffer 16384 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 4096 -smallfilesize 4096 -smallfilebuffer 16384 -compression none] $h writeFiles file1 data [lindex $datas 0] "" file1 data [lindex $datas 1] "" file1 data [lindex $datas 2] "" set result [list ""] # check the file in the small file buffer lappend result "file1 [string equal [tcltest::viewBinFile $vfs/file1] [lindex $datas 2]]" # flush the file to pages - vfs::unmount $vfs + cookfs::Unmount $vfs set fs [file size $vfs] # the file size should be (1 data [1024 bytes] + internal data) and less than (2 datas [2048 bytes]) lappend result [expr {($fs > 1024) && ($fs < 2048)}] - set h [vfs::cookfs::Mount -readonly $vfs $vfs] + set h [cookfs::Mount -readonly $vfs $vfs] # read the file again lappend result "file1 [string equal [tcltest::viewBinFile $vfs/file1] [lindex $datas 2]]" - vfs::unmount $vfs + cookfs::Unmount $vfs lappend result {} join $result \n } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } tcltest::removeFile $vfs unset -nocomplain vfs datas h result fs } -returnCodes ok -result { @@ -125,24 +125,24 @@ tcltest::test cookfsWriter-3.2 "Add the same file while previous file in in page set vfs [tcltest::makeFile {} pages.cfs] } -body { set datas [randomDatas 3 1024] - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 1024 -smallfilesize 1024 -smallfilebuffer 1024 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 1024 -smallfilesize 1024 -smallfilebuffer 1024 -compression none] $h writeFiles file1 data [lindex $datas 0] "" file1 data [lindex $datas 1] "" file1 data [lindex $datas 2] "" set result [list ""] # check the file lappend result "file1 [string equal [tcltest::viewBinFile $vfs/file1] [lindex $datas 2]]" # flush the file to pages - vfs::unmount $vfs + cookfs::Unmount $vfs set fs [file size $vfs] # the file size should be (3 datas [3072 bytes] + internal data) lappend result [expr { $fs > ( 1024 * 3 ) }] - set h [vfs::cookfs::Mount -readonly $vfs $vfs] + set h [cookfs::Mount -readonly $vfs $vfs] # read the files again lappend result "file1 [string equal [tcltest::viewBinFile $vfs/file1] [lindex $datas 2]]" - vfs::unmount $vfs + cookfs::Unmount $vfs lappend result {} join $result \n } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } tcltest::removeFile $vfs unset -nocomplain vfs datas h result fs } -returnCodes ok -result { @@ -154,10 +154,10 @@ file1 1 tcltest::test cookfsWriter-4.1 "Error while adding file by absolute name" -setup { set vfs [tcltest::makeFile {} pages.cfs] } -body { - set h [vfs::cookfs::Mount $vfs $vfs] + set h [cookfs::Mount $vfs $vfs] $h writeFiles /file1 data x "" } -cleanup { - vfs::unmount $vfs + cookfs::Unmount $vfs tcltest::removeFile $vfs unset -nocomplain vfs h } -returnCodes error -result {unable to add "/file1": Unable to create entry} @@ -171,7 +171,7 @@ tcltest::test cookfsWriter-5.1 "Channel options for added channels are preserved } -body { set result [list ""] # check small file - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 2048 -smallfilesize 2048 -smallfilebuffer 16384 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 2048 -smallfilesize 2048 -smallfilebuffer 16384 -compression none] set channel [open $file1 r] fconfigure $channel -encoding cp866 -translation cr @@ -205,11 +205,11 @@ tcltest::test cookfsWriter-5.1 "Channel options for added channels are preserved lappend result "-translation [string equal lf [fconfigure $channel -translation]]" close $channel - vfs::unmount $vfs + cookfs::Unmount $vfs lappend result {} join $result \n } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } catch { close $channel } tcltest::removeFile $vfs tcltest::removeFile $file1 @@ -232,7 +232,7 @@ tcltest::test cookfsWriter-5.2 "Channel options are preserved when error occurs" set file1 [tcltest::makeBinFile $data1 file1] } -body { set result [list ""] - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 2048 -smallfilesize 2048 -smallfilebuffer 16384 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 2048 -smallfilesize 2048 -smallfilebuffer 16384 -compression none] set channel [open $file1 r] fconfigure $channel -encoding cp866 -translation cr @@ -249,11 +249,11 @@ tcltest::test cookfsWriter-5.2 "Channel options are preserved when error occurs" lappend result "-translation [string equal lf [fconfigure $channel -translation]]" close $channel - vfs::unmount $vfs + cookfs::Unmount $vfs lappend result {} join $result \n } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } catch { close $channel } tcltest::removeFile $vfs tcltest::removeFile $file1 @@ -273,26 +273,26 @@ tcltest::test cookfsWriter-6.1 "Deleting files in a small file buffer" -setup { set result [list] set data1 [lindex [randomDatas 1 1024] 0] set data2 [lindex [randomDatas 1 4096] 0] - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 2048 -smallfilesize 2048 -smallfilebuffer 16384 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 2048 -smallfilesize 2048 -smallfilebuffer 16384 -compression none] $h writeFiles file1 data $data1 "" lappend result [file exists $vfs/file1] file delete $vfs/file1 lappend result [file exists $vfs/file1] # add some real file $h writeFiles file2 data $data2 "" - vfs::unmount $vfs + cookfs::Unmount $vfs set fs [file size $vfs] # the file size should be (1 big data [4096 bytes] + internal data) and less than (1 big data + 1 small data [5120 bytes]) lappend result [expr {($fs > 4096) && ($fs < (1024 + 4096))}] - set h [vfs::cookfs::Mount -readonly $vfs $vfs] + set h [cookfs::Mount -readonly $vfs $vfs] # file1 doesn't exist lappend result [file exists $vfs/file1] # file2 exists lappend result [file exists $vfs/file2] - vfs::unmount $vfs + cookfs::Unmount $vfs set result } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } tcltest::removeFile $vfs unset -nocomplain vfs result data1 data2 h fs } -result {1 0 1 0 1} @@ -302,7 +302,7 @@ tcltest::test cookfsWriter-6.2 "Deleting files doesn't corrupt following files i } -body { set result [list] lassign [randomDatas 2 1024] data1 data2 - set h [vfs::cookfs::Mount $vfs $vfs -pagesize 4096 -smallfilesize 4096 -smallfilebuffer 16384 -compression none] + set h [cookfs::Mount $vfs $vfs -pagesize 4096 -smallfilesize 4096 -smallfilebuffer 16384 -compression none] $h writeFiles file1 data $data1 "" file2 data $data2 "" lappend result [file exists $vfs/file1] lappend result [file exists $vfs/file2] @@ -311,20 +311,20 @@ tcltest::test cookfsWriter-6.2 "Deleting files doesn't corrupt following files i lappend result [file exists $vfs/file1] lappend result [file exists $vfs/file2] lappend result "match=[string equal [tcltest::viewBinFile $vfs/file2] $data2]" - vfs::unmount $vfs + cookfs::Unmount $vfs set fs [file size $vfs] # the file size should be (1 data [1024 bytes] + internal data) and less than (2 datas [2048 bytes]) lappend result [expr {($fs > 1024) && ($fs < (1024 * 2))}] - set h [vfs::cookfs::Mount -readonly $vfs $vfs] + set h [cookfs::Mount -readonly $vfs $vfs] # file1 doesn't exist lappend result [file exists $vfs/file1] # file2 exists lappend result [file exists $vfs/file2] lappend result "match=[string equal [tcltest::viewBinFile $vfs/file2] $data2]" - vfs::unmount $vfs + cookfs::Unmount $vfs set result } -cleanup { - catch { vfs::unmount $vfs } + catch { cookfs::Unmount $vfs } tcltest::removeFile $vfs unset -nocomplain vfs result h data2 data1 fs } -result {1 1 match=1 0 1 match=1 1 0 1 match=1}