qualified-type-ref-of-var.py 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Copyright (c) Contributors to the Open 3D Engine Project.
  5. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  6. SPDX-License-Identifier: Apache-2.0 OR MIT
  7. """
  8. import sys
  9. import os
  10. from clr import *
  11. sys.path.append("..")
  12. import testfuncs
  13. def execTest(thefile, compilerPath, silent):
  14. '''return number of successes'''
  15. symbols, ok = testfuncs.buildAndGetSymbols(thefile, compilerPath, silent)
  16. # check the specific stuff we want to verify with this test
  17. if ok:
  18. try:
  19. ok = symbols["Symbol '/func()/d'"]['type']['core']['name'] == '/C/D'
  20. ok2 = symbols["Symbol '/func()/d2'"]['type']['core']['name'] == '/C/D'
  21. ok3 = symbols["Symbol '/func()/d3'"]['type']['core']['name'] == '/func()/S'
  22. mh34Type = symbols["Symbol '/func()/mh34'"]['type']['core']['name']
  23. rwbfType = symbols["Symbol '/func()/rwbf'"]['type']
  24. sbInlType = symbols["Symbol '/func()/sbInl'"]['type']
  25. ok4 = True # TODO (wip)
  26. ok5 = rwbfType['core']['name'] == "?RWBuffer" and rwbfType['generic']['name'] == "?float4x4"
  27. ok6 = sbInlType['core']['name'] == "?StructuredBuffer" and sbInlType['generic']['name'] == "/func()/Inl" and sbInlType['generic']['tclass'] == "Struct"
  28. if not silent:
  29. if not ok:
  30. print (fg.RED+ "Couldn't verify symbol /C/D is type of /func()/d"+ style.RESET_ALL)
  31. else:
  32. print (style.BRIGHT+ "/C/D is type of /func()/d. great !"+ style.RESET_ALL)
  33. if not ok2:
  34. print (fg.RED+ "Couldn't verify symbol /C/D is type of /func()/d2"+ style.RESET_ALL)
  35. else:
  36. print (style.BRIGHT+ "/C/D is type of /func()/d2. great !"+ style.RESET_ALL)
  37. if not ok3:
  38. print (fg.RED+ "Couldn't verify symbol /func()/d3 is of type /func()/S"+ style.RESET_ALL)
  39. else:
  40. print (style.BRIGHT+ "/func()/d3 is of type /func()/S. great !"+ style.RESET_ALL)
  41. print (style.BRIGHT+ fg.YELLOW+ ("WIP: need to verify {0} is canonicalized to half3x4 ?").format(mh34Type)+ style.RESET_ALL)
  42. if not ok5:
  43. print (fg.RED+ "Couldn't verify symbol /func()/rwbf is of type ?RWBuffer<?float4x4>"+ style.RESET_ALL)
  44. else:
  45. print (style.BRIGHT+ "/func()/rwbf is of type ?RWBuffer<?float4x4>. great !"+ style.RESET_ALL)
  46. if not ok6:
  47. print (fg.RED+ "Couldn't verify symbol /func()/sbInl is of type ?StructuredBuffer< struct /func()/Inl >"+ style.RESET_ALL)
  48. else:
  49. print (style.BRIGHT+ "/func()/sbInl is of type ?StructuredBuffer< struct /fubc/Inl >. great !"+ style.RESET_ALL)
  50. ok = ok and ok2 and ok3 and ok4 and ok5 and ok6
  51. except Exception as e:
  52. print (fg.RED+ "Err: Parsed --dumpsym dictionary didn't record /func()/d symbol ?"+ style.RESET_ALL, e)
  53. ok = False
  54. return ok
  55. result = 0 # to define for sub-tests
  56. resultFailed = 0
  57. def doTests(compiler, silent, azdxcpath):
  58. global result
  59. global resultFailed
  60. # Working directory should have been set to this script's directory by the calling parent
  61. # You can get it once doTests() is called, but not during initialization of the module,
  62. # because at that time it will still be set to the working directory of the calling script
  63. workDir = os.getcwd()
  64. if execTest(os.path.join(workDir, "qualified-type-ref-of-var.azsl"), compiler, silent): result += 1
  65. else: resultFailed += 1
  66. if __name__ == "__main__":
  67. print ("please call from testapp.py")