Overview
Comment: | More tests and cleaned up error handling for POSIX error codes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e786b9e07b62f8ed996a4c845360afcc |
User & Date: | rkeene on 2019-09-16 21:02:23 |
Other Links: | manifest | tags |
Context
2019-09-16
| ||
21:19 | More tests check-in: 3d002d6892 user: rkeene tags: trunk | |
21:02 | More tests and cleaned up error handling for POSIX error codes check-in: e786b9e07b user: rkeene tags: trunk | |
20:43 | More tests and small fixes check-in: 10f67b2ced user: rkeene tags: trunk | |
Changes
Modified example/main.tcl from [5b23a3839e] to [414972be93].
︙ | ︙ | |||
69 70 71 72 73 74 75 | read $fd 1 read $fd 1 } -cleanup { close $fd unset fd } -result "" | | < | > > | > > > > > > > > > > > > > > > > > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | read $fd 1 read $fd 1 } -cleanup { close $fd unset fd } -result "" tcltest::test xvfs-basic-open-neg "Xvfs Open Non-Existant File Test" -body { unset -nocomplain fd set fd [open $rootDir/does-not-exist] } -cleanup { if {[info exists fd]} { close $fd unset fd } } -returnCodes error -result "no such file or directory" tcltest::test xvfs-basic-open-write "Xvfs Open For Writing Test" -body { unset -nocomplain fd set fd [open $rootDir/new-file w] } -cleanup { if {[info exists fd]} { close $fd unset fd } catch { file delete $rootDir/new-file } } -match glob -returnCodes error -result "*read*only file*system*" tcltest::test xvfs-basic-open-directory "Xvfs Open Directory Test" -body { unset -nocomplain fd set fd [open $rootDir/lib] set fd } -cleanup { if {[info exists fd]} { close $fd unset fd } } -match glob -returnCodes error -result "*illegal operation on a directory" tcltest::test xvfs-basic-two-files "Xvfs Multiple Open Files Test" -setup { set fd1 [open $testFile] set fd2 [open $testFile] } -body { set data1 [read $fd1] close $fd1 set data2 [read $fd2] |
︙ | ︙ | |||
186 187 188 189 190 191 192 193 194 195 196 197 198 199 | tcltest::test xvfs-stat-basic-file "Xvfs stat Basic File Test" -body { file stat $testFile fileInfo set fileInfo(type) } -cleanup { unset -nocomplain fileInfo } -result file tcltest::test xvfs-stat-basic-dir "Xvfs stat Basic Directory Test" -body { file stat $rootDir/lib fileInfo set fileInfo(type) } -cleanup { unset -nocomplain fileInfo } -result directory | > > > > > > | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | tcltest::test xvfs-stat-basic-file "Xvfs stat Basic File Test" -body { file stat $testFile fileInfo set fileInfo(type) } -cleanup { unset -nocomplain fileInfo } -result file tcltest::test xvfs-stat-basic-file-neg "Xvfs stat Basic File Negative Test" -body { file stat $rootDir/does-not-exist fileInfo } -cleanup { unset -nocomplain fileInfo } -match glob -returnCodes error -result "*no such file or directory" tcltest::test xvfs-stat-basic-dir "Xvfs stat Basic Directory Test" -body { file stat $rootDir/lib fileInfo set fileInfo(type) } -cleanup { unset -nocomplain fileInfo } -result directory |
︙ | ︙ |
Modified xvfs-core.c from [ecbc07c77d] to [20368f703a].
︙ | ︙ | |||
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | return(Tcl_ErrnoMsg(xvfs_errorToErrno(xvfs_error))); case XVFS_RV_ERR_INTERNAL: return("Internal error"); default: return("Unknown error"); } } /* * Xvfs Memory Channel */ struct xvfs_tclfs_channel_id { Tcl_Channel channel; struct xvfs_tclfs_instance_info *fsInstanceInfo; Tcl_Obj *path; Tcl_WideInt currentOffset; Tcl_WideInt fileSize; int eofMarked; int queuedEvents; int closed; }; struct xvfs_tclfs_channel_event { Tcl_Event tcl; struct xvfs_tclfs_channel_id *channelInstanceData; }; static Tcl_ChannelType xvfs_tclfs_channelType; | > > > > > > > > > > > | > > > > > > > > > > > | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | return(Tcl_ErrnoMsg(xvfs_errorToErrno(xvfs_error))); case XVFS_RV_ERR_INTERNAL: return("Internal error"); default: return("Unknown error"); } } static void xvfs_setresults_error(Tcl_Interp *interp, int xvfs_error) { if (!interp) { return; } Tcl_SetErrno(xvfs_errorToErrno(xvfs_error)); Tcl_SetResult(interp, (char *) xvfs_perror(xvfs_error), NULL); return; } /* * Xvfs Memory Channel */ struct xvfs_tclfs_channel_id { Tcl_Channel channel; struct xvfs_tclfs_instance_info *fsInstanceInfo; Tcl_Obj *path; Tcl_WideInt currentOffset; Tcl_WideInt fileSize; int eofMarked; int queuedEvents; int closed; }; struct xvfs_tclfs_channel_event { Tcl_Event tcl; struct xvfs_tclfs_channel_id *channelInstanceData; }; static Tcl_ChannelType xvfs_tclfs_channelType; static Tcl_Channel xvfs_tclfs_openChannel(Tcl_Interp *interp, Tcl_Obj *path, struct xvfs_tclfs_instance_info *instanceInfo) { struct xvfs_tclfs_channel_id *channelInstanceData; Tcl_Channel channel; Tcl_StatBuf fileInfo; Tcl_Obj *channelName; int statRet; XVFS_DEBUG_ENTER; XVFS_DEBUG_PRINTF("Opening file \"%s\" ...", Tcl_GetString(path)); statRet = instanceInfo->fsInfo->getStatProc(Tcl_GetString(path), &fileInfo); if (statRet < 0) { XVFS_DEBUG_PRINTF("... failed: %s", xvfs_perror(statRet)); xvfs_setresults_error(interp, XVFS_RV_ERR_ENOENT); XVFS_DEBUG_LEAVE; return(NULL); } if (fileInfo.st_mode & 040000) { XVFS_DEBUG_PUTS("... failed (cannot open directories)"); xvfs_setresults_error(interp, XVFS_RV_ERR_EISDIR); XVFS_DEBUG_LEAVE; return(NULL); } channelInstanceData = (struct xvfs_tclfs_channel_id *) Tcl_Alloc(sizeof(*channelInstanceData)); channelInstanceData->currentOffset = 0; |
︙ | ︙ | |||
573 574 575 576 577 578 579 | XVFS_DEBUG_ENTER; XVFS_DEBUG_PRINTF("Asked to open(\"%s\", %x)...", Tcl_GetString(path), mode); if (mode & O_WRONLY) { XVFS_DEBUG_PUTS("... failed (asked to open for writing)"); | < | < < | | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | XVFS_DEBUG_ENTER; XVFS_DEBUG_PRINTF("Asked to open(\"%s\", %x)...", Tcl_GetString(path), mode); if (mode & O_WRONLY) { XVFS_DEBUG_PUTS("... failed (asked to open for writing)"); xvfs_setresults_error(interp, XVFS_RV_ERR_EROFS); XVFS_DEBUG_LEAVE; return(NULL); } path = xvfs_absolutePath(path); pathStr = xvfs_relativePath(path, instanceInfo); pathRel = Tcl_NewStringObj(pathStr, -1); Tcl_DecrRefCount(path); XVFS_DEBUG_PUTS("... done, passing off to channel handler"); retval = xvfs_tclfs_openChannel(interp, pathRel, instanceInfo); XVFS_DEBUG_LEAVE; return(retval); } static int xvfs_tclfs_verifyType(Tcl_Obj *path, Tcl_GlobTypeData *types, struct xvfs_tclfs_instance_info *instanceInfo) { const char *pathStr; |
︙ | ︙ | |||
730 731 732 733 734 735 736 | pathStr = xvfs_relativePath(path, instanceInfo); if (!pathStr) { XVFS_DEBUG_PUTS("... error (not in our VFS)"); Tcl_DecrRefCount(path); | < | < < | < | 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | pathStr = xvfs_relativePath(path, instanceInfo); if (!pathStr) { XVFS_DEBUG_PUTS("... error (not in our VFS)"); Tcl_DecrRefCount(path); xvfs_setresults_error(interp, XVFS_RV_ERR_ENOENT); XVFS_DEBUG_LEAVE; return(TCL_OK); } childrenCount = 0; children = instanceInfo->fsInfo->getChildrenProc(pathStr, &childrenCount); if (childrenCount < 0) { XVFS_DEBUG_PRINTF("... error: %s", xvfs_perror(childrenCount)); Tcl_DecrRefCount(path); xvfs_setresults_error(interp, childrenCount); XVFS_DEBUG_LEAVE; return(TCL_ERROR); } for (idx = 0; idx < childrenCount; idx++) { child = children[idx]; |
︙ | ︙ |