<> <> <> DIRECTORY File, FileInternal, Random, Rope, SafeStorage; PropertiesExtendTester: CEDAR PROGRAM IMPORTS File, Random, SafeStorage = BEGIN DoTest: PROC [numberOfExtends: INT, maxNumberOfPages: INT ] = { file: File.Handle; fileFP: File.FP; propPages: File.PageCount; props: File.PropertyStorage; randomStream: Random.RandomStream; volume: File.Volume; offset: WORD; randomStream _ Random.Create[range: 10000, seed: -1] ; offset _ Random.ChooseInt[randomStream, 1, 1000]; volume _ File.SystemVolume[]; file _ File.Create[volume: volume, size: 30] ; [fp: fileFP] _ File.Info[file]; [prop: props, nPages: propPages] _ File.GetProperties[file: file]; IF propPages # 1 THEN ERROR; setProps[file, offset, props, File.wordsPerPage]; file _ NIL; SafeStorage.ReclaimCollectibleObjects[suspendMe: TRUE, traceAndSweep: FALSE]; SafeStorage.ReclaimCollectibleObjects[suspendMe: TRUE, traceAndSweep: FALSE]; FOR loopCount: INT IN [0 .. numberOfExtends) DO growAmount: INT; nowProps: File.PropertyStorage; nowPropPages: File.PageCount; nowWords: CARDINAL; growAmount _ Random.ChooseInt[randomStream, 1, maxNumberOfPages]; file _ File.Open[volume: volume, fp: fileFP]; [prop: nowProps, nPages: nowPropPages] _ File.GetProperties[file: file]; IF nowPropPages # propPages THEN ERROR; nowWords _ nowPropPages * File.wordsPerPage; testProps[offset, nowProps, nowWords]; propPages _ propPages + growAmount; file.SetPropertiesSize[nPages: propPages]; [prop: nowProps, nPages: nowPropPages] _ File.GetProperties[file: file]; IF nowPropPages # propPages THEN ERROR; setProps[file, offset, nowProps, propPages*File.wordsPerPage]; file _ NIL; SafeStorage.ReclaimCollectibleObjects[suspendMe: TRUE, traceAndSweep: FALSE]; SafeStorage.ReclaimCollectibleObjects[suspendMe: TRUE, traceAndSweep: FALSE]; SafeStorage.ReclaimCollectibleObjects[suspendMe: TRUE, traceAndSweep: FALSE]; SafeStorage.ReclaimCollectibleObjects[suspendMe: TRUE, traceAndSweep: FALSE]; ENDLOOP; file _ File.Open[volume: volume, fp: fileFP]; file.Delete[]; }; testProps: PROC [offset: WORD, props: File.PropertyStorage, propWords: CARDINAL] = TRUSTED { FOR ptr: CARDINAL IN [0..propWords) DO IF props[ptr] # ptr+offset THEN ERROR; ENDLOOP; }; setProps: PROC [file: File.Handle, offset: WORD, props: File.PropertyStorage, propWords: CARDINAL] = TRUSTED { FOR ptr: CARDINAL IN [0..propWords) DO props[ptr] _ ptr+offset; ENDLOOP; file.WriteProperties[]; }; <> END. <<>>