#!/bin/env python
#
# We have to mount the same share to test, test1, test2 directories that locate in the directory we
# execute this script from.

from os import open, close, O_RDWR, O_CREAT, write, read, O_RDONLY, O_WRONLY, O_TRUNC, lseek

f = open('test/_test4321_', O_RDWR | O_CREAT | O_TRUNC)
write(f, ''.join('a' for _ in range(4096)))
close(f)

f1 = open('test1/_test4321_', O_RDWR)
f2 = open('test2/_test4321_', O_RDWR)

write(f1, 'x')
print 'x is written through f1'
print '%c is read from f2' % read(f2, 1)

write(f1, 'y')
print 'y is written through f1'
print '%c is read from f2' % read(f2, 1)

write(f1, 'z')
print 'z is written through f1'
print '%c is read from f2' % read(f2, 1)

close(f1)
close(f2)
