wscript 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #! /usr/bin/env python
  2. from waflib import Utils, Build, Logs
  3. import os
  4. GRP = os.environ.get('WAF_TEST_GROUP', 'adm')
  5. def test_chown(bld):
  6. def create_and_chown(tsk):
  7. tsk.outputs[0].write('test')
  8. Utils.lchown(tsk.outputs[0].abspath(), -1, GRP)
  9. bld.conf.env.CAN_CHOWN = True
  10. bld(rule=create_and_chown, target='foo.txt', always=True)
  11. def test_grp(bld):
  12. def check_path(tsk):
  13. import grp
  14. entry = grp.getgrnam(GRP)
  15. assert entry[0] == GRP
  16. bld.conf.env.CAN_GRP = True
  17. bld(rule=check_path, always=True)
  18. def test_chown_install(bld):
  19. bld.is_install = Build.INSTALL
  20. dest_file = bld.bldnode.make_node('test/foo')
  21. dest_link = bld.bldnode.make_node('test/foo_link')
  22. tmpfile = bld.bldnode.make_node('foo.txt')
  23. tmpfile.write('this is a test')
  24. bld.install_as(dest_file,
  25. tmpfile,
  26. install_group=GRP)
  27. bld.symlink_as(dest_link,
  28. 'foo',
  29. install_group=GRP)
  30. bld.add_group()
  31. def check_path(tsk):
  32. import grp
  33. gid = grp.getgrnam(GRP)[2]
  34. assert os.stat(dest_file.abspath()).st_gid == gid
  35. assert os.stat(dest_link.abspath()).st_gid == gid
  36. bld(rule=check_path, always=True)
  37. def configure(conf):
  38. conf.test(build_fun=test_grp,
  39. msg='Checking for the python module grp',
  40. okmsg='ok',
  41. errmsg='grp is missing',
  42. mandatory=False)
  43. if not conf.env.CAN_GRP:
  44. return
  45. conf.test(build_fun=test_chown,
  46. msg='Checking for Utils.lchown',
  47. okmsg='ok',
  48. errmsg='chown does not seem to work',
  49. mandatory=False)
  50. if not conf.env.CAN_CHOWN:
  51. return
  52. conf.test(build_fun=test_chown_install,
  53. msg='Testing install_group="adm"',
  54. okmsg='ok',
  55. errmsg='there is a regression')
  56. def build(bld):
  57. pass