''' 
	Access Control Lists testing based on newpynfs framework 
	Aurelien Charbon - Bull SA
'''
from random_gen import *
import commands
import os
import threading
import time
import random

alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_-() ~'
t_alphabet=len(alphabet)

def test_longacl(path):
	# mesures sur le getfacl
	test = RandomGen()
	
	u = commands.getoutput('rm ' + path + "/*")	# clean directory
	print "test acl getfacl\n"
	for i in range(40):
		test.getUserList()
		testfile = 'testfile' + str(i)
		u = commands.getoutput('touch ' + path + "/" + testfile)
		print "setfacl with " + str(i) + "entries\n " + u
		for j in range(i):
			user = test.uList.pop()
			mode = test.createRandomMode()
                        u = commands.getoutput('setfacl -m u:' + user + ':' + mode + " " + path + "/" + testfile)
		
def main():
	path = '/mnt/nfs/test-acl'
	test_longacl(path)

main()

