Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a41042a2 authored by Aditya Choudhary's avatar Aditya Choudhary Committed by Automerger Merge Worker
Browse files

Merge "Refactor metadata tool to support metadata generation for different...

Merge "Refactor metadata tool to support metadata generation for different rules." into main am: 432c41ec

Original change: https://android-review.googlesource.com/c/platform/build/+/2833290



Change-Id: I711bb6ca26d52cc96f3f1cecf1eed5cbe9e6b36b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ccdb708c 432c41ec
Loading
Loading
Loading
Loading

tools/metadata/OWNERS

0 → 100644
+4 −0
Original line number Diff line number Diff line
dariofreni@google.com
joeo@google.com
ronish@google.com
caditya@google.com
+28 −20
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ func readFileToString(filePath string) string {
	return string(data)
}

func processProtobuf(
func processTestSpecProtobuf(
	filePath string, ownershipMetadataMap *sync.Map, keyLocks *keyToLocksMap,
	errCh chan error, wg *sync.WaitGroup,
) {
@@ -130,10 +130,11 @@ func processProtobuf(
func main() {
	inputFile := flag.String("inputFile", "", "Input file path")
	outputFile := flag.String("outputFile", "", "Output file path")
	rule := flag.String("rule", "", "Metadata rule (Hint: test_spec or code_metadata)")
	flag.Parse()

	if *inputFile == "" || *outputFile == "" {
		fmt.Println("Usage: metadata -inputFile <input file path> -outputFile <output file path>")
	if *inputFile == "" || *outputFile == "" || *rule == "" {
		fmt.Println("Usage: metadata -rule <rule> -inputFile <input file path> -outputFile <output file path>")
		os.Exit(1)
	}

@@ -144,9 +145,11 @@ func main() {
	errCh := make(chan error, len(filePaths))
	var wg sync.WaitGroup

	switch *rule {
	case "test_spec":
		for _, filePath := range filePaths {
			wg.Add(1)
		go processProtobuf(filePath, ownershipMetadataMap, keyLocks, errCh, &wg)
			go processTestSpecProtobuf(filePath, ownershipMetadataMap, keyLocks, errCh, &wg)
		}

		wg.Wait()
@@ -166,4 +169,9 @@ func main() {
		}

		writeOutput(*outputFile, allMetadata)
		break
	case "code_metadata":
	default:
		log.Fatalf("No specific processing implemented for rule '%s'.\n", *rule)
	}
}
+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import (

func TestMetadata(t *testing.T) {
	cmd := exec.Command(
		"metadata", "-inputFile", "./inputFiles.txt", "-outputFile",
		"metadata", "-rule", "test_spec", "-inputFile", "./inputFiles.txt", "-outputFile",
		"./generatedOutputFile.txt",
	)
	stderr, err := cmd.CombinedOutput()
@@ -40,7 +40,7 @@ func TestMetadata(t *testing.T) {

func TestMetadataNegativeCase(t *testing.T) {
	cmd := exec.Command(
		"metadata", "-inputFile", "./inputFilesNegativeCase.txt", "-outputFile",
		"metadata", "-rule", "test_spec", "-inputFile", "./inputFilesNegativeCase.txt", "-outputFile",
		"./generatedOutputFileNegativeCase.txt",
	)
	stderr, err := cmd.CombinedOutput()