| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697 |
- // Copyright 2018 The go-ethereum Authors
- // This file is part of the go-ethereum library.
- //
- // The go-ethereum library is free software: you can redistribute it and/or modify
- // it under the terms of the GNU Lesser General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // The go-ethereum library is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU Lesser General Public License for more details.
- //
- // You should have received a copy of the GNU Lesser General Public License
- // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
- // +build linux darwin freebsd
- package fuse
- import (
- "bytes"
- "context"
- "crypto/rand"
- "flag"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "testing"
- "github.com/ethereum/go-ethereum/swarm/api"
- "github.com/ethereum/go-ethereum/swarm/storage"
- "github.com/ethereum/go-ethereum/log"
- colorable "github.com/mattn/go-colorable"
- )
- var (
- loglevel = flag.Int("loglevel", 4, "verbosity of logs")
- rawlog = flag.Bool("rawlog", false, "turn off terminal formatting in logs")
- longrunning = flag.Bool("longrunning", false, "do run long-running tests")
- )
- func init() {
- flag.Parse()
- log.PrintOrigins(true)
- log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(!*rawlog))))
- }
- type fileInfo struct {
- perm uint64
- uid int
- gid int
- contents []byte
- }
- //create files from the map of name and content provided and upload them to swarm via api
- func createTestFilesAndUploadToSwarm(t *testing.T, api *api.API, files map[string]fileInfo, uploadDir string, toEncrypt bool) string {
- //iterate the map
- for fname, finfo := range files {
- actualPath := filepath.Join(uploadDir, fname)
- filePath := filepath.Dir(actualPath)
- //create directory
- err := os.MkdirAll(filePath, 0777)
- if err != nil {
- t.Fatalf("Error creating directory '%v' : %v", filePath, err)
- }
- //create file
- fd, err1 := os.OpenFile(actualPath, os.O_RDWR|os.O_CREATE, os.FileMode(finfo.perm))
- if err1 != nil {
- t.Fatalf("Error creating file %v: %v", actualPath, err1)
- }
- //write content to file
- _, err = fd.Write(finfo.contents)
- if err != nil {
- t.Fatalf("Error writing to file '%v' : %v", filePath, err)
- }
- /*
- Note @holisticode: It's not clear why the Chown command was added to the test suite.
- Some files are initialized with different permissions in the individual test,
- resulting in errors on Chown which were not checked.
- After adding the checks tests would fail.
- What's then the reason to have this check in the first place?
- Disabling for now
- err = fd.Chown(finfo.uid, finfo.gid)
- if err != nil {
- t.Fatalf("Error chown file '%v' : %v", filePath, err)
- }
- */
- err = fd.Chmod(os.FileMode(finfo.perm))
- if err != nil {
- t.Fatalf("Error chmod file '%v' : %v", filePath, err)
- }
- err = fd.Sync()
- if err != nil {
- t.Fatalf("Error sync file '%v' : %v", filePath, err)
- }
- err = fd.Close()
- if err != nil {
- t.Fatalf("Error closing file '%v' : %v", filePath, err)
- }
- }
- //upload directory to swarm and return hash
- bzzhash, err := api.Upload(context.TODO(), uploadDir, "", toEncrypt)
- if err != nil {
- t.Fatalf("Error uploading directory %v: %vm encryption: %v", uploadDir, err, toEncrypt)
- }
- return bzzhash
- }
- //mount a swarm hash as a directory on files system via FUSE
- func mountDir(t *testing.T, api *api.API, files map[string]fileInfo, bzzHash string, mountDir string) *SwarmFS {
- swarmfs := NewSwarmFS(api)
- _, err := swarmfs.Mount(bzzHash, mountDir)
- if isFUSEUnsupportedError(err) {
- t.Skip("FUSE not supported:", err)
- } else if err != nil {
- t.Fatalf("Error mounting hash %v: %v", bzzHash, err)
- }
- //check directory is mounted
- found := false
- mi := swarmfs.Listmounts()
- for _, minfo := range mi {
- minfo.lock.RLock()
- if minfo.MountPoint == mountDir {
- if minfo.StartManifest != bzzHash ||
- minfo.LatestManifest != bzzHash ||
- minfo.fuseConnection == nil {
- minfo.lock.RUnlock()
- t.Fatalf("Error mounting: exp(%s): act(%s)", bzzHash, minfo.StartManifest)
- }
- found = true
- }
- minfo.lock.RUnlock()
- }
- // Test listMounts
- if !found {
- t.Fatalf("Error getting mounts information for %v: %v", mountDir, err)
- }
- // Check if file and their attributes are as expected
- compareGeneratedFileWithFileInMount(t, files, mountDir)
- return swarmfs
- }
- // Check if file and their attributes are as expected
- func compareGeneratedFileWithFileInMount(t *testing.T, files map[string]fileInfo, mountDir string) {
- err := filepath.Walk(mountDir, func(path string, f os.FileInfo, err error) error {
- if f.IsDir() {
- return nil
- }
- fname := path[len(mountDir)+1:]
- if _, ok := files[fname]; !ok {
- t.Fatalf(" file %v present in mount dir and is not expected", fname)
- }
- return nil
- })
- if err != nil {
- t.Fatalf("Error walking dir %v", mountDir)
- }
- for fname, finfo := range files {
- destinationFile := filepath.Join(mountDir, fname)
- dfinfo, err := os.Stat(destinationFile)
- if err != nil {
- t.Fatalf("Destination file %v missing in mount: %v", fname, err)
- }
- if int64(len(finfo.contents)) != dfinfo.Size() {
- t.Fatalf("file %v Size mismatch source (%v) vs destination(%v)", fname, int64(len(finfo.contents)), dfinfo.Size())
- }
- if dfinfo.Mode().Perm().String() != "-rwx------" {
- t.Fatalf("file %v Permission mismatch source (-rwx------) vs destination(%v)", fname, dfinfo.Mode().Perm())
- }
- fileContents, err := ioutil.ReadFile(filepath.Join(mountDir, fname))
- if err != nil {
- t.Fatalf("Could not readfile %v : %v", fname, err)
- }
- if !bytes.Equal(fileContents, finfo.contents) {
- t.Fatalf("File %v contents mismatch: %v , %v", fname, fileContents, finfo.contents)
- }
- // TODO: check uid and gid
- }
- }
- //check mounted file with provided content
- func checkFile(t *testing.T, testMountDir, fname string, contents []byte) {
- destinationFile := filepath.Join(testMountDir, fname)
- dfinfo, err1 := os.Stat(destinationFile)
- if err1 != nil {
- t.Fatalf("Could not stat file %v", destinationFile)
- }
- if dfinfo.Size() != int64(len(contents)) {
- t.Fatalf("Mismatch in size actual(%v) vs expected(%v)", dfinfo.Size(), int64(len(contents)))
- }
- fd, err2 := os.OpenFile(destinationFile, os.O_RDONLY, os.FileMode(0665))
- if err2 != nil {
- t.Fatalf("Could not open file %v", destinationFile)
- }
- newcontent := make([]byte, len(contents))
- _, err := fd.Read(newcontent)
- if err != nil {
- t.Fatalf("Could not read from file %v", err)
- }
- err = fd.Close()
- if err != nil {
- t.Fatalf("Could not close file %v", err)
- }
- if !bytes.Equal(contents, newcontent) {
- t.Fatalf("File content mismatch expected (%v): received (%v) ", contents, newcontent)
- }
- }
- func getRandomBytes(size int) []byte {
- contents := make([]byte, size)
- rand.Read(contents)
- return contents
- }
- func isDirEmpty(name string) bool {
- f, err := os.Open(name)
- if err != nil {
- return false
- }
- defer f.Close()
- _, err = f.Readdirnames(1)
- return err == io.EOF
- }
- type testAPI struct {
- api *api.API
- }
- type testData struct {
- testDir string
- testUploadDir string
- testMountDir string
- bzzHash string
- files map[string]fileInfo
- toEncrypt bool
- swarmfs *SwarmFS
- }
- //create the root dir of a test
- func (ta *testAPI) initSubtest(name string) (*testData, error) {
- var err error
- d := &testData{}
- d.testDir, err = ioutil.TempDir(os.TempDir(), name)
- if err != nil {
- return nil, fmt.Errorf("Couldn't create test dir: %v", err)
- }
- return d, nil
- }
- //upload data and mount directory
- func (ta *testAPI) uploadAndMount(dat *testData, t *testing.T) (*testData, error) {
- //create upload dir
- err := os.MkdirAll(dat.testUploadDir, 0777)
- if err != nil {
- return nil, fmt.Errorf("Couldn't create upload dir: %v", err)
- }
- //create mount dir
- err = os.MkdirAll(dat.testMountDir, 0777)
- if err != nil {
- return nil, fmt.Errorf("Couldn't create mount dir: %v", err)
- }
- //upload the file
- dat.bzzHash = createTestFilesAndUploadToSwarm(t, ta.api, dat.files, dat.testUploadDir, dat.toEncrypt)
- log.Debug("Created test files and uploaded to Swarm")
- //mount the directory
- dat.swarmfs = mountDir(t, ta.api, dat.files, dat.bzzHash, dat.testMountDir)
- log.Debug("Mounted swarm fs")
- return dat, nil
- }
- //add a directory to the test directory tree
- func addDir(root string, name string) (string, error) {
- d := filepath.Join(root, name)
- err := os.MkdirAll(d, 0777)
- if err != nil {
- return "", fmt.Errorf("Couldn't create dir inside test dir: %v", err)
- }
- return d, nil
- }
- func (ta *testAPI) mountListAndUnmountEncrypted(t *testing.T) {
- log.Debug("Starting mountListAndUnmountEncrypted test")
- ta.mountListAndUnmount(t, true)
- log.Debug("Test mountListAndUnmountEncrypted terminated")
- }
- func (ta *testAPI) mountListAndUnmountNonEncrypted(t *testing.T) {
- log.Debug("Starting mountListAndUnmountNonEncrypted test")
- ta.mountListAndUnmount(t, false)
- log.Debug("Test mountListAndUnmountNonEncrypted terminated")
- }
- //mount a directory unmount and check the directory is empty afterwards
- func (ta *testAPI) mountListAndUnmount(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("mountListAndUnmount")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "testUploadDir")
- dat.testMountDir = filepath.Join(dat.testDir, "testMountDir")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["2.txt"] = fileInfo{0711, 333, 444, getRandomBytes(10)}
- dat.files["3.txt"] = fileInfo{0622, 333, 444, getRandomBytes(100)}
- dat.files["4.txt"] = fileInfo{0533, 333, 444, getRandomBytes(1024)}
- dat.files["5.txt"] = fileInfo{0544, 333, 444, getRandomBytes(10)}
- dat.files["6.txt"] = fileInfo{0555, 333, 444, getRandomBytes(10)}
- dat.files["7.txt"] = fileInfo{0666, 333, 444, getRandomBytes(10)}
- dat.files["8.txt"] = fileInfo{0777, 333, 333, getRandomBytes(10)}
- dat.files["11.txt"] = fileInfo{0777, 333, 444, getRandomBytes(10)}
- dat.files["111.txt"] = fileInfo{0777, 333, 444, getRandomBytes(10)}
- dat.files["two/2.txt"] = fileInfo{0777, 333, 444, getRandomBytes(10)}
- dat.files["two/2/2.txt"] = fileInfo{0777, 333, 444, getRandomBytes(10)}
- dat.files["two/2./2.txt"] = fileInfo{0777, 444, 444, getRandomBytes(10)}
- dat.files["twice/2.txt"] = fileInfo{0777, 444, 333, getRandomBytes(200)}
- dat.files["one/two/three/four/five/six/seven/eight/nine/10.txt"] = fileInfo{0777, 333, 444, getRandomBytes(10240)}
- dat.files["one/two/three/four/five/six/six"] = fileInfo{0777, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Check unmount
- _, err = dat.swarmfs.Unmount(dat.testMountDir)
- if err != nil {
- t.Fatalf("could not unmount %v", dat.bzzHash)
- }
- log.Debug("Unmount successful")
- if !isDirEmpty(dat.testMountDir) {
- t.Fatalf("unmount didnt work for %v", dat.testMountDir)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) maxMountsEncrypted(t *testing.T) {
- log.Debug("Starting maxMountsEncrypted test")
- ta.runMaxMounts(t, true)
- log.Debug("Test maxMountsEncrypted terminated")
- }
- func (ta *testAPI) maxMountsNonEncrypted(t *testing.T) {
- log.Debug("Starting maxMountsNonEncrypted test")
- ta.runMaxMounts(t, false)
- log.Debug("Test maxMountsNonEncrypted terminated")
- }
- //mount several different directories until the maximum has been reached
- func (ta *testAPI) runMaxMounts(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("runMaxMounts")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "max-upload1")
- dat.testMountDir = filepath.Join(dat.testDir, "max-mount1")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- dat.testUploadDir = filepath.Join(dat.testDir, "max-upload2")
- dat.testMountDir = filepath.Join(dat.testDir, "max-mount2")
- dat.files["2.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- dat.testUploadDir = filepath.Join(dat.testDir, "max-upload3")
- dat.testMountDir = filepath.Join(dat.testDir, "max-mount3")
- dat.files["3.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- dat.testUploadDir = filepath.Join(dat.testDir, "max-upload4")
- dat.testMountDir = filepath.Join(dat.testDir, "max-mount4")
- dat.files["4.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- dat.testUploadDir = filepath.Join(dat.testDir, "max-upload5")
- dat.testMountDir = filepath.Join(dat.testDir, "max-mount5")
- dat.files["5.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- //now try an additional mount, should fail due to max mounts reached
- testUploadDir6 := filepath.Join(dat.testDir, "max-upload6")
- err = os.MkdirAll(testUploadDir6, 0777)
- if err != nil {
- t.Fatalf("Couldn't create upload dir 6: %v", err)
- }
- dat.files["6.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- testMountDir6 := filepath.Join(dat.testDir, "max-mount6")
- err = os.MkdirAll(testMountDir6, 0777)
- if err != nil {
- t.Fatalf("Couldn't create mount dir 5: %v", err)
- }
- bzzHash6 := createTestFilesAndUploadToSwarm(t, ta.api, dat.files, testUploadDir6, toEncrypt)
- log.Debug("Created test files and uploaded to swarm with uploadDir6")
- _, err = dat.swarmfs.Mount(bzzHash6, testMountDir6)
- if err == nil {
- t.Fatalf("Expected this mount to fail due to exceeding max number of allowed mounts, but succeeded. %v", bzzHash6)
- }
- log.Debug("Maximum mount reached, additional mount failed. Correct.")
- }
- func (ta *testAPI) remountEncrypted(t *testing.T) {
- log.Debug("Starting remountEncrypted test")
- ta.remount(t, true)
- log.Debug("Test remountEncrypted terminated")
- }
- func (ta *testAPI) remountNonEncrypted(t *testing.T) {
- log.Debug("Starting remountNonEncrypted test")
- ta.remount(t, false)
- log.Debug("Test remountNonEncrypted terminated")
- }
- //test remounting same hash second time and different hash in already mounted point
- func (ta *testAPI) remount(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("remount")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "remount-upload1")
- dat.testMountDir = filepath.Join(dat.testDir, "remount-mount1")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // try mounting the same hash second time
- testMountDir2, err2 := addDir(dat.testDir, "remount-mount2")
- if err2 != nil {
- t.Fatalf("Error creating second mount dir: %v", err2)
- }
- _, err2 = dat.swarmfs.Mount(dat.bzzHash, testMountDir2)
- if err2 != nil {
- t.Fatalf("Error mounting hash second time on different dir %v", dat.bzzHash)
- }
- // mount a different hash in already mounted point
- dat.files["2.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- testUploadDir2, err3 := addDir(dat.testDir, "remount-upload2")
- if err3 != nil {
- t.Fatalf("Error creating second upload dir: %v", err3)
- }
- bzzHash2 := createTestFilesAndUploadToSwarm(t, ta.api, dat.files, testUploadDir2, toEncrypt)
- _, err = swarmfs.Mount(bzzHash2, dat.testMountDir)
- if err == nil {
- t.Fatalf("Error mounting hash %v", bzzHash2)
- }
- log.Debug("Mount on existing mount point failed. Correct.")
- // mount nonexistent hash
- failDir, err3 := addDir(dat.testDir, "remount-fail")
- if err3 != nil {
- t.Fatalf("Error creating remount dir: %v", bzzHash2)
- }
- failHash := "0xfea11223344"
- _, err = swarmfs.Mount(failHash, failDir)
- if err == nil {
- t.Fatalf("Expected this mount to fail due to non existing hash. But succeeded %v", failHash)
- }
- log.Debug("Nonexistent hash hasn't been mounted. Correct.")
- }
- func (ta *testAPI) unmountEncrypted(t *testing.T) {
- log.Debug("Starting unmountEncrypted test")
- ta.unmount(t, true)
- log.Debug("Test unmountEncrypted terminated")
- }
- func (ta *testAPI) unmountNonEncrypted(t *testing.T) {
- log.Debug("Starting unmountNonEncrypted test")
- ta.unmount(t, false)
- log.Debug("Test unmountNonEncrypted terminated")
- }
- //mount then unmount and check that it has been unmounted
- func (ta *testAPI) unmount(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("unmount")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "ex-upload1")
- dat.testMountDir = filepath.Join(dat.testDir, "ex-mount1")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- _, err = dat.swarmfs.Unmount(dat.testMountDir)
- if err != nil {
- t.Fatalf("could not unmount %v", dat.bzzHash)
- }
- log.Debug("Unmounted Dir")
- mi := swarmfs.Listmounts()
- log.Debug("Going to list mounts")
- for _, minfo := range mi {
- log.Debug("Mount point in list: ", "point", minfo.MountPoint)
- if minfo.MountPoint == dat.testMountDir {
- t.Fatalf("mount state not cleaned up in unmount case %v", dat.testMountDir)
- }
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) unmountWhenResourceBusyEncrypted(t *testing.T) {
- log.Debug("Starting unmountWhenResourceBusyEncrypted test")
- ta.unmountWhenResourceBusy(t, true)
- log.Debug("Test unmountWhenResourceBusyEncrypted terminated")
- }
- func (ta *testAPI) unmountWhenResourceBusyNonEncrypted(t *testing.T) {
- log.Debug("Starting unmountWhenResourceBusyNonEncrypted test")
- ta.unmountWhenResourceBusy(t, false)
- log.Debug("Test unmountWhenResourceBusyNonEncrypted terminated")
- }
- //unmount while a resource is busy; should fail
- func (ta *testAPI) unmountWhenResourceBusy(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("unmountWhenResourceBusy")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "ex-upload1")
- dat.testMountDir = filepath.Join(dat.testDir, "ex-mount1")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- //create a file in the mounted directory, then try to unmount - should fail
- actualPath := filepath.Join(dat.testMountDir, "2.txt")
- //d, err := os.OpenFile(actualPath, os.O_RDWR, os.FileMode(0700))
- d, err := os.Create(actualPath)
- if err != nil {
- t.Fatalf("Couldn't create new file: %v", err)
- }
- //we need to manually close the file before mount for this test
- //but let's defer too in case of errors
- defer d.Close()
- _, err = d.Write(getRandomBytes(10))
- if err != nil {
- t.Fatalf("Couldn't write to file: %v", err)
- }
- log.Debug("Bytes written")
- _, err = dat.swarmfs.Unmount(dat.testMountDir)
- if err == nil {
- t.Fatalf("Expected mount to fail due to resource busy, but it succeeded...")
- }
- //free resources
- err = d.Close()
- if err != nil {
- t.Fatalf("Couldn't close file! %v", dat.bzzHash)
- }
- log.Debug("File closed")
- //now unmount after explicitly closed file
- _, err = dat.swarmfs.Unmount(dat.testMountDir)
- if err != nil {
- t.Fatalf("Expected mount to succeed after freeing resource, but it failed: %v", err)
- }
- //check if the dir is still mounted
- mi := dat.swarmfs.Listmounts()
- log.Debug("Going to list mounts")
- for _, minfo := range mi {
- log.Debug("Mount point in list: ", "point", minfo.MountPoint)
- if minfo.MountPoint == dat.testMountDir {
- t.Fatalf("mount state not cleaned up in unmount case %v", dat.testMountDir)
- }
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) seekInMultiChunkFileEncrypted(t *testing.T) {
- log.Debug("Starting seekInMultiChunkFileEncrypted test")
- ta.seekInMultiChunkFile(t, true)
- log.Debug("Test seekInMultiChunkFileEncrypted terminated")
- }
- func (ta *testAPI) seekInMultiChunkFileNonEncrypted(t *testing.T) {
- log.Debug("Starting seekInMultiChunkFileNonEncrypted test")
- ta.seekInMultiChunkFile(t, false)
- log.Debug("Test seekInMultiChunkFileNonEncrypted terminated")
- }
- //open a file in a mounted dir and go to a certain position
- func (ta *testAPI) seekInMultiChunkFile(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("seekInMultiChunkFile")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "seek-upload1")
- dat.testMountDir = filepath.Join(dat.testDir, "seek-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10240)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Open the file in the mounted dir and seek the second chunk
- actualPath := filepath.Join(dat.testMountDir, "1.txt")
- d, err := os.OpenFile(actualPath, os.O_RDONLY, os.FileMode(0700))
- if err != nil {
- t.Fatalf("Couldn't open file: %v", err)
- }
- log.Debug("Opened file")
- defer func() {
- err := d.Close()
- if err != nil {
- t.Fatalf("Error closing file! %v", err)
- }
- }()
- _, err = d.Seek(5000, 0)
- if err != nil {
- t.Fatalf("Error seeking in file: %v", err)
- }
- contents := make([]byte, 1024)
- _, err = d.Read(contents)
- if err != nil {
- t.Fatalf("Error reading file: %v", err)
- }
- log.Debug("Read contents")
- finfo := dat.files["1.txt"]
- if !bytes.Equal(finfo.contents[:6024][5000:], contents) {
- t.Fatalf("File seek contents mismatch")
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) createNewFileEncrypted(t *testing.T) {
- log.Debug("Starting createNewFileEncrypted test")
- ta.createNewFile(t, true)
- log.Debug("Test createNewFileEncrypted terminated")
- }
- func (ta *testAPI) createNewFileNonEncrypted(t *testing.T) {
- log.Debug("Starting createNewFileNonEncrypted test")
- ta.createNewFile(t, false)
- log.Debug("Test createNewFileNonEncrypted terminated")
- }
- //create a new file in a mounted swarm directory,
- //unmount the fuse dir and then remount to see if new file is still there
- func (ta *testAPI) createNewFile(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("createNewFile")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "create-upload1")
- dat.testMountDir = filepath.Join(dat.testDir, "create-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["five.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["six.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Create a new file in the root dir and check
- actualPath := filepath.Join(dat.testMountDir, "2.txt")
- d, err1 := os.OpenFile(actualPath, os.O_RDWR|os.O_CREATE, os.FileMode(0665))
- if err1 != nil {
- t.Fatalf("Could not open file %s : %v", actualPath, err1)
- }
- defer d.Close()
- log.Debug("Opened file")
- contents := make([]byte, 11)
- _, err = rand.Read(contents)
- if err != nil {
- t.Fatalf("Could not rand read contents %v", err)
- }
- log.Debug("content read")
- _, err = d.Write(contents)
- if err != nil {
- t.Fatalf("Couldn't write contents: %v", err)
- }
- log.Debug("content written")
- err = d.Close()
- if err != nil {
- t.Fatalf("Couldn't close file: %v", err)
- }
- log.Debug("file closed")
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("Directory unmounted")
- testMountDir2, err3 := addDir(dat.testDir, "create-mount2")
- if err3 != nil {
- t.Fatalf("Error creating mount dir2: %v", err3)
- }
- // mount again and see if things are okay
- dat.files["2.txt"] = fileInfo{0700, 333, 444, contents}
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, testMountDir2)
- log.Debug("Directory mounted again")
- checkFile(t, testMountDir2, "2.txt", contents)
- _, err2 = dat.swarmfs.Unmount(testMountDir2)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) createNewFileInsideDirectoryEncrypted(t *testing.T) {
- log.Debug("Starting createNewFileInsideDirectoryEncrypted test")
- ta.createNewFileInsideDirectory(t, true)
- log.Debug("Test createNewFileInsideDirectoryEncrypted terminated")
- }
- func (ta *testAPI) createNewFileInsideDirectoryNonEncrypted(t *testing.T) {
- log.Debug("Starting createNewFileInsideDirectoryNonEncrypted test")
- ta.createNewFileInsideDirectory(t, false)
- log.Debug("Test createNewFileInsideDirectoryNonEncrypted terminated")
- }
- //create a new file inside a directory inside the mount
- func (ta *testAPI) createNewFileInsideDirectory(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("createNewFileInsideDirectory")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "createinsidedir-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "createinsidedir-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["one/1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Create a new file inside a existing dir and check
- dirToCreate := filepath.Join(dat.testMountDir, "one")
- actualPath := filepath.Join(dirToCreate, "2.txt")
- d, err1 := os.OpenFile(actualPath, os.O_RDWR|os.O_CREATE, os.FileMode(0665))
- if err1 != nil {
- t.Fatalf("Could not create file %s : %v", actualPath, err1)
- }
- defer d.Close()
- log.Debug("File opened")
- contents := make([]byte, 11)
- _, err = rand.Read(contents)
- if err != nil {
- t.Fatalf("Error filling random bytes into byte array %v", err)
- }
- log.Debug("Content read")
- _, err = d.Write(contents)
- if err != nil {
- t.Fatalf("Error writing random bytes into file %v", err)
- }
- log.Debug("Content written")
- err = d.Close()
- if err != nil {
- t.Fatalf("Error closing file %v", err)
- }
- log.Debug("File closed")
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("Directory unmounted")
- testMountDir2, err3 := addDir(dat.testDir, "createinsidedir-mount2")
- if err3 != nil {
- t.Fatalf("Error creating mount dir2: %v", err3)
- }
- // mount again and see if things are okay
- dat.files["one/2.txt"] = fileInfo{0700, 333, 444, contents}
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, testMountDir2)
- log.Debug("Directory mounted again")
- checkFile(t, testMountDir2, "one/2.txt", contents)
- _, err = dat.swarmfs.Unmount(testMountDir2)
- if err != nil {
- t.Fatalf("could not unmount %v", dat.bzzHash)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) createNewFileInsideNewDirectoryEncrypted(t *testing.T) {
- log.Debug("Starting createNewFileInsideNewDirectoryEncrypted test")
- ta.createNewFileInsideNewDirectory(t, true)
- log.Debug("Test createNewFileInsideNewDirectoryEncrypted terminated")
- }
- func (ta *testAPI) createNewFileInsideNewDirectoryNonEncrypted(t *testing.T) {
- log.Debug("Starting createNewFileInsideNewDirectoryNonEncrypted test")
- ta.createNewFileInsideNewDirectory(t, false)
- log.Debug("Test createNewFileInsideNewDirectoryNonEncrypted terminated")
- }
- //create a new directory in mount and a new file
- func (ta *testAPI) createNewFileInsideNewDirectory(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("createNewFileInsideNewDirectory")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "createinsidenewdir-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "createinsidenewdir-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Create a new file inside a existing dir and check
- dirToCreate, err2 := addDir(dat.testMountDir, "one")
- if err2 != nil {
- t.Fatalf("Error creating mount dir2: %v", err2)
- }
- actualPath := filepath.Join(dirToCreate, "2.txt")
- d, err1 := os.OpenFile(actualPath, os.O_RDWR|os.O_CREATE, os.FileMode(0665))
- if err1 != nil {
- t.Fatalf("Could not create file %s : %v", actualPath, err1)
- }
- defer d.Close()
- log.Debug("File opened")
- contents := make([]byte, 11)
- _, err = rand.Read(contents)
- if err != nil {
- t.Fatalf("Error writing random bytes to byte array: %v", err)
- }
- log.Debug("content read")
- _, err = d.Write(contents)
- if err != nil {
- t.Fatalf("Error writing to file: %v", err)
- }
- log.Debug("content written")
- err = d.Close()
- if err != nil {
- t.Fatalf("Error closing file: %v", err)
- }
- log.Debug("File closed")
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("Directory unmounted")
- // mount again and see if things are okay
- dat.files["one/2.txt"] = fileInfo{0700, 333, 444, contents}
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, dat.testMountDir)
- log.Debug("Directory mounted again")
- checkFile(t, dat.testMountDir, "one/2.txt", contents)
- _, err2 = dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) removeExistingFileEncrypted(t *testing.T) {
- log.Debug("Starting removeExistingFileEncrypted test")
- ta.removeExistingFile(t, true)
- log.Debug("Test removeExistingFileEncrypted terminated")
- }
- func (ta *testAPI) removeExistingFileNonEncrypted(t *testing.T) {
- log.Debug("Starting removeExistingFileNonEncrypted test")
- ta.removeExistingFile(t, false)
- log.Debug("Test removeExistingFileNonEncrypted terminated")
- }
- //remove existing file in mount
- func (ta *testAPI) removeExistingFile(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("removeExistingFile")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "remove-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "remove-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["five.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["six.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Remove a file in the root dir and check
- actualPath := filepath.Join(dat.testMountDir, "five.txt")
- err = os.Remove(actualPath)
- if err != nil {
- t.Fatalf("Error removing file! %v", err)
- }
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("Directory unmounted")
- // mount again and see if things are okay
- delete(dat.files, "five.txt")
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, dat.testMountDir)
- _, err = os.Stat(actualPath)
- if err == nil {
- t.Fatal("Expected file to not be present in re-mount after removal, but it is there")
- }
- _, err2 = dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) removeExistingFileInsideDirEncrypted(t *testing.T) {
- log.Debug("Starting removeExistingFileInsideDirEncrypted test")
- ta.removeExistingFileInsideDir(t, true)
- log.Debug("Test removeExistingFileInsideDirEncrypted terminated")
- }
- func (ta *testAPI) removeExistingFileInsideDirNonEncrypted(t *testing.T) {
- log.Debug("Starting removeExistingFileInsideDirNonEncrypted test")
- ta.removeExistingFileInsideDir(t, false)
- log.Debug("Test removeExistingFileInsideDirNonEncrypted terminated")
- }
- //remove a file inside a directory inside a mount
- func (ta *testAPI) removeExistingFileInsideDir(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("removeExistingFileInsideDir")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "remove-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "remove-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["one/five.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["one/six.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Remove a file in the root dir and check
- actualPath := filepath.Join(dat.testMountDir, "one")
- actualPath = filepath.Join(actualPath, "five.txt")
- err = os.Remove(actualPath)
- if err != nil {
- t.Fatalf("Error removing file! %v", err)
- }
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("Directory unmounted")
- // mount again and see if things are okay
- delete(dat.files, "one/five.txt")
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, dat.testMountDir)
- _, err = os.Stat(actualPath)
- if err == nil {
- t.Fatal("Expected file to not be present in re-mount after removal, but it is there")
- }
- okPath := filepath.Join(dat.testMountDir, "one")
- okPath = filepath.Join(okPath, "six.txt")
- _, err = os.Stat(okPath)
- if err != nil {
- t.Fatal("Expected file to be present in re-mount after removal, but it is not there")
- }
- _, err2 = dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) removeNewlyAddedFileEncrypted(t *testing.T) {
- log.Debug("Starting removeNewlyAddedFileEncrypted test")
- ta.removeNewlyAddedFile(t, true)
- log.Debug("Test removeNewlyAddedFileEncrypted terminated")
- }
- func (ta *testAPI) removeNewlyAddedFileNonEncrypted(t *testing.T) {
- log.Debug("Starting removeNewlyAddedFileNonEncrypted test")
- ta.removeNewlyAddedFile(t, false)
- log.Debug("Test removeNewlyAddedFileNonEncrypted terminated")
- }
- //add a file in mount and then remove it; on remount file should not be there
- func (ta *testAPI) removeNewlyAddedFile(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("removeNewlyAddedFile")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "removenew-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "removenew-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["five.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["six.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Add a a new file and remove it
- dirToCreate := filepath.Join(dat.testMountDir, "one")
- err = os.MkdirAll(dirToCreate, os.FileMode(0665))
- if err != nil {
- t.Fatalf("Error creating dir in mounted dir: %v", err)
- }
- actualPath := filepath.Join(dirToCreate, "2.txt")
- d, err1 := os.OpenFile(actualPath, os.O_RDWR|os.O_CREATE, os.FileMode(0665))
- if err1 != nil {
- t.Fatalf("Could not create file %s : %v", actualPath, err1)
- }
- defer d.Close()
- log.Debug("file opened")
- contents := make([]byte, 11)
- _, err = rand.Read(contents)
- if err != nil {
- t.Fatalf("Error writing random bytes to byte array: %v", err)
- }
- log.Debug("content read")
- _, err = d.Write(contents)
- if err != nil {
- t.Fatalf("Error writing random bytes to file: %v", err)
- }
- log.Debug("content written")
- err = d.Close()
- if err != nil {
- t.Fatalf("Error closing file: %v", err)
- }
- log.Debug("file closed")
- checkFile(t, dat.testMountDir, "one/2.txt", contents)
- log.Debug("file checked")
- err = os.Remove(actualPath)
- if err != nil {
- t.Fatalf("Error removing file: %v", err)
- }
- log.Debug("file removed")
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("Directory unmounted")
- testMountDir2, err3 := addDir(dat.testDir, "removenew-mount2")
- if err3 != nil {
- t.Fatalf("Error creating mount dir2: %v", err3)
- }
- // mount again and see if things are okay
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, testMountDir2)
- log.Debug("Directory mounted again")
- if dat.bzzHash != mi.LatestManifest {
- t.Fatalf("same contents different hash orig(%v): new(%v)", dat.bzzHash, mi.LatestManifest)
- }
- _, err2 = dat.swarmfs.Unmount(testMountDir2)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) addNewFileAndModifyContentsEncrypted(t *testing.T) {
- log.Debug("Starting addNewFileAndModifyContentsEncrypted test")
- ta.addNewFileAndModifyContents(t, true)
- log.Debug("Test addNewFileAndModifyContentsEncrypted terminated")
- }
- func (ta *testAPI) addNewFileAndModifyContentsNonEncrypted(t *testing.T) {
- log.Debug("Starting addNewFileAndModifyContentsNonEncrypted test")
- ta.addNewFileAndModifyContents(t, false)
- log.Debug("Test addNewFileAndModifyContentsNonEncrypted terminated")
- }
- //add a new file and modify content; remount and check the modified file is intact
- func (ta *testAPI) addNewFileAndModifyContents(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("addNewFileAndModifyContents")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "modifyfile-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "modifyfile-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["five.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["six.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- // Create a new file in the root dir
- actualPath := filepath.Join(dat.testMountDir, "2.txt")
- d, err1 := os.OpenFile(actualPath, os.O_RDWR|os.O_CREATE, os.FileMode(0665))
- if err1 != nil {
- t.Fatalf("Could not create file %s : %v", actualPath, err1)
- }
- defer d.Close()
- //write some random data into the file
- log.Debug("file opened")
- line1 := []byte("Line 1")
- _, err = rand.Read(line1)
- if err != nil {
- t.Fatalf("Error writing random bytes to byte array: %v", err)
- }
- log.Debug("line read")
- _, err = d.Write(line1)
- if err != nil {
- t.Fatalf("Error writing random bytes to file: %v", err)
- }
- log.Debug("line written")
- err = d.Close()
- if err != nil {
- t.Fatalf("Error closing file: %v", err)
- }
- log.Debug("file closed")
- //unmount the hash on the mounted dir
- mi1, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- log.Debug("Directory unmounted")
- //mount on a different dir to see if modified file is correct
- testMountDir2, err3 := addDir(dat.testDir, "modifyfile-mount2")
- if err3 != nil {
- t.Fatalf("Error creating mount dir2: %v", err3)
- }
- dat.files["2.txt"] = fileInfo{0700, 333, 444, line1}
- _ = mountDir(t, ta.api, dat.files, mi1.LatestManifest, testMountDir2)
- log.Debug("Directory mounted again")
- checkFile(t, testMountDir2, "2.txt", line1)
- log.Debug("file checked")
- //unmount second dir
- mi2, err4 := dat.swarmfs.Unmount(testMountDir2)
- if err4 != nil {
- t.Fatalf("Could not unmount %v", err4)
- }
- log.Debug("Directory unmounted again")
- //mount again on original dir and modify the file
- //let's clean up the mounted dir first: remove...
- err = os.RemoveAll(dat.testMountDir)
- if err != nil {
- t.Fatalf("Error cleaning up mount dir: %v", err)
- }
- //...and re-create
- err = os.MkdirAll(dat.testMountDir, 0777)
- if err != nil {
- t.Fatalf("Error re-creating mount dir: %v", err)
- }
- //now remount
- _ = mountDir(t, ta.api, dat.files, mi2.LatestManifest, dat.testMountDir)
- log.Debug("Directory mounted yet again")
- //open the file....
- fd, err5 := os.OpenFile(actualPath, os.O_RDWR|os.O_APPEND, os.FileMode(0665))
- if err5 != nil {
- t.Fatalf("Could not create file %s : %v", actualPath, err5)
- }
- defer fd.Close()
- log.Debug("file opened")
- //...and modify something
- line2 := []byte("Line 2")
- _, err = rand.Read(line2)
- if err != nil {
- t.Fatalf("Error modifying random bytes to byte array: %v", err)
- }
- log.Debug("line read")
- _, err = fd.Seek(int64(len(line1)), 0)
- if err != nil {
- t.Fatalf("Error seeking position for modification: %v", err)
- }
- _, err = fd.Write(line2)
- if err != nil {
- t.Fatalf("Error modifying file: %v", err)
- }
- log.Debug("line written")
- err = fd.Close()
- if err != nil {
- t.Fatalf("Error closing modified file; %v", err)
- }
- log.Debug("file closed")
- //unmount the modified directory
- mi3, err6 := dat.swarmfs.Unmount(dat.testMountDir)
- if err6 != nil {
- t.Fatalf("Could not unmount %v", err6)
- }
- log.Debug("Directory unmounted yet again")
- //now remount on a different dir and check that the modified file is ok
- testMountDir4, err7 := addDir(dat.testDir, "modifyfile-mount4")
- if err7 != nil {
- t.Fatalf("Could not unmount %v", err7)
- }
- b := [][]byte{line1, line2}
- line1and2 := bytes.Join(b, []byte(""))
- dat.files["2.txt"] = fileInfo{0700, 333, 444, line1and2}
- _ = mountDir(t, ta.api, dat.files, mi3.LatestManifest, testMountDir4)
- log.Debug("Directory mounted final time")
- checkFile(t, testMountDir4, "2.txt", line1and2)
- _, err = dat.swarmfs.Unmount(testMountDir4)
- if err != nil {
- t.Fatalf("Could not unmount %v", err)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) removeEmptyDirEncrypted(t *testing.T) {
- log.Debug("Starting removeEmptyDirEncrypted test")
- ta.removeEmptyDir(t, true)
- log.Debug("Test removeEmptyDirEncrypted terminated")
- }
- func (ta *testAPI) removeEmptyDirNonEncrypted(t *testing.T) {
- log.Debug("Starting removeEmptyDirNonEncrypted test")
- ta.removeEmptyDir(t, false)
- log.Debug("Test removeEmptyDirNonEncrypted terminated")
- }
- //remove an empty dir inside mount
- func (ta *testAPI) removeEmptyDir(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("removeEmptyDir")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "rmdir-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "rmdir-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["five.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["six.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- _, err2 := addDir(dat.testMountDir, "newdir")
- if err2 != nil {
- t.Fatalf("Could not unmount %v", err2)
- }
- mi, err := dat.swarmfs.Unmount(dat.testMountDir)
- if err != nil {
- t.Fatalf("Could not unmount %v", err)
- }
- log.Debug("Directory unmounted")
- //by just adding an empty dir, the hash doesn't change; test this
- if dat.bzzHash != mi.LatestManifest {
- t.Fatalf("same contents different hash orig(%v): new(%v)", dat.bzzHash, mi.LatestManifest)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) removeDirWhichHasFilesEncrypted(t *testing.T) {
- log.Debug("Starting removeDirWhichHasFilesEncrypted test")
- ta.removeDirWhichHasFiles(t, true)
- log.Debug("Test removeDirWhichHasFilesEncrypted terminated")
- }
- func (ta *testAPI) removeDirWhichHasFilesNonEncrypted(t *testing.T) {
- log.Debug("Starting removeDirWhichHasFilesNonEncrypted test")
- ta.removeDirWhichHasFiles(t, false)
- log.Debug("Test removeDirWhichHasFilesNonEncrypted terminated")
- }
- //remove a directory with a file; check on remount file isn't there
- func (ta *testAPI) removeDirWhichHasFiles(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("removeDirWhichHasFiles")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "rmdir-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "rmdir-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["one/1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["two/five.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["two/six.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- //delete a directory inside the mounted dir with all its files
- dirPath := filepath.Join(dat.testMountDir, "two")
- err = os.RemoveAll(dirPath)
- if err != nil {
- t.Fatalf("Error removing directory in mounted dir: %v", err)
- }
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v ", err2)
- }
- log.Debug("Directory unmounted")
- //we deleted files in the OS, so let's delete them also in the files map
- delete(dat.files, "two/five.txt")
- delete(dat.files, "two/six.txt")
- // mount again and see if deleted files have been deleted indeed
- testMountDir2, err3 := addDir(dat.testDir, "remount-mount2")
- if err3 != nil {
- t.Fatalf("Could not unmount %v", err3)
- }
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, testMountDir2)
- log.Debug("Directory mounted")
- actualPath := filepath.Join(dirPath, "five.txt")
- _, err = os.Stat(actualPath)
- if err == nil {
- t.Fatal("Expected file to not be present in re-mount after removal, but it is there")
- }
- _, err = os.Stat(dirPath)
- if err == nil {
- t.Fatal("Expected file to not be present in re-mount after removal, but it is there")
- }
- _, err = dat.swarmfs.Unmount(testMountDir2)
- if err != nil {
- t.Fatalf("Could not unmount %v", err)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) removeDirWhichHasSubDirsEncrypted(t *testing.T) {
- log.Debug("Starting removeDirWhichHasSubDirsEncrypted test")
- ta.removeDirWhichHasSubDirs(t, true)
- log.Debug("Test removeDirWhichHasSubDirsEncrypted terminated")
- }
- func (ta *testAPI) removeDirWhichHasSubDirsNonEncrypted(t *testing.T) {
- log.Debug("Starting removeDirWhichHasSubDirsNonEncrypted test")
- ta.removeDirWhichHasSubDirs(t, false)
- log.Debug("Test removeDirWhichHasSubDirsNonEncrypted terminated")
- }
- //remove a directory with subdirectories inside mount; on remount check they are not there
- func (ta *testAPI) removeDirWhichHasSubDirs(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("removeDirWhichHasSubDirs")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "rmsubdir-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "rmsubdir-mount")
- dat.files = make(map[string]fileInfo)
- dat.files["one/1.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["two/three/2.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["two/three/3.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["two/four/5.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["two/four/6.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat.files["two/four/six/7.txt"] = fileInfo{0700, 333, 444, getRandomBytes(10)}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- dirPath := filepath.Join(dat.testMountDir, "two")
- err = os.RemoveAll(dirPath)
- if err != nil {
- t.Fatalf("Error removing directory in mounted dir: %v", err)
- }
- //delete a directory inside the mounted dir with all its files
- mi, err2 := dat.swarmfs.Unmount(dat.testMountDir)
- if err2 != nil {
- t.Fatalf("Could not unmount %v ", err2)
- }
- log.Debug("Directory unmounted")
- //we deleted files in the OS, so let's delete them also in the files map
- delete(dat.files, "two/three/2.txt")
- delete(dat.files, "two/three/3.txt")
- delete(dat.files, "two/four/5.txt")
- delete(dat.files, "two/four/6.txt")
- delete(dat.files, "two/four/six/7.txt")
- // mount again and see if things are okay
- testMountDir2, err3 := addDir(dat.testDir, "remount-mount2")
- if err3 != nil {
- t.Fatalf("Could not unmount %v", err3)
- }
- _ = mountDir(t, ta.api, dat.files, mi.LatestManifest, testMountDir2)
- log.Debug("Directory mounted again")
- actualPath := filepath.Join(dirPath, "three")
- actualPath = filepath.Join(actualPath, "2.txt")
- _, err = os.Stat(actualPath)
- if err == nil {
- t.Fatal("Expected file to not be present in re-mount after removal, but it is there")
- }
- actualPath = filepath.Join(dirPath, "four")
- _, err = os.Stat(actualPath)
- if err == nil {
- t.Fatal("Expected file to not be present in re-mount after removal, but it is there")
- }
- _, err = os.Stat(dirPath)
- if err == nil {
- t.Fatal("Expected file to not be present in re-mount after removal, but it is there")
- }
- _, err = dat.swarmfs.Unmount(testMountDir2)
- if err != nil {
- t.Fatalf("Could not unmount %v", err)
- }
- log.Debug("subtest terminated")
- }
- func (ta *testAPI) appendFileContentsToEndEncrypted(t *testing.T) {
- log.Debug("Starting appendFileContentsToEndEncrypted test")
- ta.appendFileContentsToEnd(t, true)
- log.Debug("Test appendFileContentsToEndEncrypted terminated")
- }
- func (ta *testAPI) appendFileContentsToEndNonEncrypted(t *testing.T) {
- log.Debug("Starting appendFileContentsToEndNonEncrypted test")
- ta.appendFileContentsToEnd(t, false)
- log.Debug("Test appendFileContentsToEndNonEncrypted terminated")
- }
- //append contents to the end of a file; remount and check it's intact
- func (ta *testAPI) appendFileContentsToEnd(t *testing.T, toEncrypt bool) {
- dat, err := ta.initSubtest("appendFileContentsToEnd")
- if err != nil {
- t.Fatalf("Couldn't initialize subtest dirs: %v", err)
- }
- defer os.RemoveAll(dat.testDir)
- dat.toEncrypt = toEncrypt
- dat.testUploadDir = filepath.Join(dat.testDir, "appendlargefile-upload")
- dat.testMountDir = filepath.Join(dat.testDir, "appendlargefile-mount")
- dat.files = make(map[string]fileInfo)
- line1 := make([]byte, 10)
- _, err = rand.Read(line1)
- if err != nil {
- t.Fatalf("Error writing random bytes to byte array: %v", err)
- }
- dat.files["1.txt"] = fileInfo{0700, 333, 444, line1}
- dat, err = ta.uploadAndMount(dat, t)
- if err != nil {
- t.Fatalf("Error during upload of files to swarm / mount of swarm dir: %v", err)
- }
- defer dat.swarmfs.Stop()
- actualPath := filepath.Join(dat.testMountDir, "1.txt")
- fd, err4 := os.OpenFile(actualPath, os.O_RDWR|os.O_APPEND, os.FileMode(0665))
- if err4 != nil {
- t.Fatalf("Could not create file %s : %v", actualPath, err4)
- }
- defer fd.Close()
- log.Debug("file opened")
- line2 := make([]byte, 5)
- _, err = rand.Read(line2)
- if err != nil {
- t.Fatalf("Error writing random bytes to byte array: %v", err)
- }
- log.Debug("line read")
- _, err = fd.Seek(int64(len(line1)), 0)
- if err != nil {
- t.Fatalf("Error searching for position to append: %v", err)
- }
- _, err = fd.Write(line2)
- if err != nil {
- t.Fatalf("Error appending: %v", err)
- }
- log.Debug("line written")
- err = fd.Close()
- if err != nil {
- t.Fatalf("Error closing file: %v", err)
- }
- log.Debug("file closed")
- mi1, err5 := dat.swarmfs.Unmount(dat.testMountDir)
- if err5 != nil {
- t.Fatalf("Could not unmount %v ", err5)
- }
- log.Debug("Directory unmounted")
- // mount again and see if appended file is correct
- b := [][]byte{line1, line2}
- line1and2 := bytes.Join(b, []byte(""))
- dat.files["1.txt"] = fileInfo{0700, 333, 444, line1and2}
- testMountDir2, err6 := addDir(dat.testDir, "remount-mount2")
- if err6 != nil {
- t.Fatalf("Could not unmount %v", err6)
- }
- _ = mountDir(t, ta.api, dat.files, mi1.LatestManifest, testMountDir2)
- log.Debug("Directory mounted")
- checkFile(t, testMountDir2, "1.txt", line1and2)
- _, err = dat.swarmfs.Unmount(testMountDir2)
- if err != nil {
- t.Fatalf("Could not unmount %v", err)
- }
- log.Debug("subtest terminated")
- }
- //run all the tests
- func TestFUSE(t *testing.T) {
- t.Skip("disable fuse tests until they are stable")
- //create a data directory for swarm
- datadir, err := ioutil.TempDir("", "fuse")
- if err != nil {
- t.Fatalf("unable to create temp dir: %v", err)
- }
- defer os.RemoveAll(datadir)
- fileStore, err := storage.NewLocalFileStore(datadir, make([]byte, 32))
- if err != nil {
- t.Fatal(err)
- }
- ta := &testAPI{api: api.NewAPI(fileStore, nil, nil, nil)}
- //run a short suite of tests
- //approx time: 28s
- t.Run("mountListAndUnmountEncrypted", ta.mountListAndUnmountEncrypted)
- t.Run("remountEncrypted", ta.remountEncrypted)
- t.Run("unmountWhenResourceBusyNonEncrypted", ta.unmountWhenResourceBusyNonEncrypted)
- t.Run("removeExistingFileEncrypted", ta.removeExistingFileEncrypted)
- t.Run("addNewFileAndModifyContentsNonEncrypted", ta.addNewFileAndModifyContentsNonEncrypted)
- t.Run("removeDirWhichHasFilesNonEncrypted", ta.removeDirWhichHasFilesNonEncrypted)
- t.Run("appendFileContentsToEndEncrypted", ta.appendFileContentsToEndEncrypted)
- //provide longrunning flag to execute all tests
- //approx time with longrunning: 140s
- if *longrunning {
- t.Run("mountListAndUnmountNonEncrypted", ta.mountListAndUnmountNonEncrypted)
- t.Run("maxMountsEncrypted", ta.maxMountsEncrypted)
- t.Run("maxMountsNonEncrypted", ta.maxMountsNonEncrypted)
- t.Run("remountNonEncrypted", ta.remountNonEncrypted)
- t.Run("unmountEncrypted", ta.unmountEncrypted)
- t.Run("unmountNonEncrypted", ta.unmountNonEncrypted)
- t.Run("unmountWhenResourceBusyEncrypted", ta.unmountWhenResourceBusyEncrypted)
- t.Run("unmountWhenResourceBusyNonEncrypted", ta.unmountWhenResourceBusyNonEncrypted)
- t.Run("seekInMultiChunkFileEncrypted", ta.seekInMultiChunkFileEncrypted)
- t.Run("seekInMultiChunkFileNonEncrypted", ta.seekInMultiChunkFileNonEncrypted)
- t.Run("createNewFileEncrypted", ta.createNewFileEncrypted)
- t.Run("createNewFileNonEncrypted", ta.createNewFileNonEncrypted)
- t.Run("createNewFileInsideDirectoryEncrypted", ta.createNewFileInsideDirectoryEncrypted)
- t.Run("createNewFileInsideDirectoryNonEncrypted", ta.createNewFileInsideDirectoryNonEncrypted)
- t.Run("createNewFileInsideNewDirectoryEncrypted", ta.createNewFileInsideNewDirectoryEncrypted)
- t.Run("createNewFileInsideNewDirectoryNonEncrypted", ta.createNewFileInsideNewDirectoryNonEncrypted)
- t.Run("removeExistingFileNonEncrypted", ta.removeExistingFileNonEncrypted)
- t.Run("removeExistingFileInsideDirEncrypted", ta.removeExistingFileInsideDirEncrypted)
- t.Run("removeExistingFileInsideDirNonEncrypted", ta.removeExistingFileInsideDirNonEncrypted)
- t.Run("removeNewlyAddedFileEncrypted", ta.removeNewlyAddedFileEncrypted)
- t.Run("removeNewlyAddedFileNonEncrypted", ta.removeNewlyAddedFileNonEncrypted)
- t.Run("addNewFileAndModifyContentsEncrypted", ta.addNewFileAndModifyContentsEncrypted)
- t.Run("removeEmptyDirEncrypted", ta.removeEmptyDirEncrypted)
- t.Run("removeEmptyDirNonEncrypted", ta.removeEmptyDirNonEncrypted)
- t.Run("removeDirWhichHasFilesEncrypted", ta.removeDirWhichHasFilesEncrypted)
- t.Run("removeDirWhichHasSubDirsEncrypted", ta.removeDirWhichHasSubDirsEncrypted)
- t.Run("removeDirWhichHasSubDirsNonEncrypted", ta.removeDirWhichHasSubDirsNonEncrypted)
- t.Run("appendFileContentsToEndNonEncrypted", ta.appendFileContentsToEndNonEncrypted)
- }
- }
|