Merge vk-gl-cts/vulkan-cts-1.1.4 into vk-gl-cts/vulkan-cts-1.1.5
[platform/upstream/VK-GL-CTS.git] / external / openglcts / scripts / verify_kc_cts_rev.py
1 # -*- coding: utf-8 -*-
2
3 #-------------------------------------------------------------------------
4 # Khronos OpenGL CTS
5 # ------------------
6 #
7 # Copyright (c) 2016 The Khronos Group Inc.
8 #
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 #      http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 #
21 #-------------------------------------------------------------------------
22
23 import os
24 import sys
25 import shutil
26 import argparse
27 import subprocess
28
29 sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
30 from fetch_kc_cts import SHA1
31
32 sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
33 from build.common import *
34
35
36 EXTERNAL_DIR    = os.path.realpath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")))
37
38 def computeChecksum (data):
39         return hashlib.sha256(data).hexdigest()
40
41 class Source:
42         def __init__(self, baseDir, extractDir):
43                 self.baseDir            = baseDir
44                 self.extractDir         = extractDir
45
46         def clean (self):
47                 fullDstPath = os.path.join(EXTERNAL_DIR, self.baseDir, self.extractDir)
48                 if os.path.exists(fullDstPath):
49                         shutil.rmtree(fullDstPath, ignore_errors=False)
50
51 class GitRepo (Source):
52         def __init__(self, url, revision, baseDir, extractDir = "src"):
53                 Source.__init__(self, baseDir, extractDir)
54                 self.url                = url
55                 self.revision   = revision
56
57         def update (self):
58                 fullDstPath = os.path.join(EXTERNAL_DIR, self.baseDir, self.extractDir)
59
60                 if not os.path.exists(fullDstPath):
61                         execute(["git", "clone", "--no-checkout", self.url, fullDstPath])
62
63                 pushWorkingDir(fullDstPath)
64                 try:
65                         execute(["git", "fetch", self.url, "+refs/heads/*:refs/remotes/origin/*"])
66                         execute(["git", "checkout", self.revision])
67                 finally:
68                         popWorkingDir()
69         def compare_rev(self):
70                 fullDstPath = os.path.join(EXTERNAL_DIR, self.baseDir, self.extractDir)
71                 pushWorkingDir(fullDstPath)
72                 try:
73                         out = subprocess.check_output(["git", "rev-parse", "HEAD"])
74                         if out.replace('\n', '') != SHA1:
75                                 raise Exception ("KC CTS checkout revision %s in external/fetch_kc_cts.py doesn't match KC CTS master HEAD revision %s" % (SHA1, out))
76                 finally:
77                         popWorkingDir()
78
79 PACKAGES = [
80         GitRepo(
81                 "git@gitlab.khronos.org:opengl/kc-cts.git",
82                 "HEAD",
83                 "kc-cts"),
84 ]
85
86 if __name__ == "__main__":
87         for pkg in PACKAGES:
88                 pkg.update()
89                 pkg.compare_rev()