Skip to content

Commit

Permalink
Add copyright notice and license id to remaining source files (#159)
Browse files Browse the repository at this point in the history
* Add copyright notice and license id to remaining source files
* Update line numbers in P4 source files for expected warning/error messages

Signed-off-by: Andy Fingerhut <[email protected]>
  • Loading branch information
jafingerhut authored Feb 10, 2025
1 parent 5daad6a commit e8f2f4b
Show file tree
Hide file tree
Showing 18 changed files with 296 additions and 35 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2020 The P4-Constraints Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

FROM ubuntu:16.04

ARG DEBIAN_FRONTEND=noninteractive
Expand Down
16 changes: 16 additions & 0 deletions e2e_tests/action_restrictions_invalid.p4
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2023 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include <v1model.p4>

type bit<16> custom_type_t;
Expand Down
16 changes: 16 additions & 0 deletions e2e_tests/action_restrictions_valid.p4
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2023 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include <v1model.p4>

struct headers {};
Expand Down
16 changes: 16 additions & 0 deletions e2e_tests/common.p4
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2021 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include <v1model.p4>

#define IPv4_ETHER_TYPE 0x0800
Expand Down
54 changes: 27 additions & 27 deletions e2e_tests/invalid_constraints.expected.output
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Syntax error: @entry_restriction must be enclosed in '("' and '")'
- In @entry_restriction of table 'invalid_constraints.empty_restriction'; at offset line 1, column 1:
Parse error: unexpected token: <END_OF_INPUT>. Expected true, false, <BINARY>, <OCTARY>, <DECIMAL>, <HEXADEC>, <ID>, ::, !, -, or (.

- e2e_tests/invalid_constraints.p4:21:3:
- e2e_tests/invalid_constraints.p4:37:3:
Parse error: unexpected token: <END_OF_INPUT>. Expected true, false, <BINARY>, <OCTARY>, <DECIMAL>, <HEXADEC>, <ID>, ::, !, -, or (.

- e2e_tests/invalid_constraints.p4:27:5-15:
- e2e_tests/invalid_constraints.p4:43:5-15:
|
27 | foo.bar.baz == 2
43 | foo.bar.baz == 2
| ^^^^^^^^^^^
Type error: unknown key foo.bar.baz

Expand All @@ -22,9 +22,9 @@ Type error: unknown key foo.bar.baz
| ^^^^^^^^^^^
Type error: unknown key foo.bar.baz

- e2e_tests/invalid_constraints.p4:38:21-22:
- e2e_tests/invalid_constraints.p4:54:21-22:
|
38 | foo.bar.baz == 0b2
54 | foo.bar.baz == 0b2
| ^^
Parse error: unexpected token: <ID>. Expected <END_OF_INPUT>, ), ::, &&, ;, ||, ->, ==, !=, >, >=, <, or <=.

Expand All @@ -33,56 +33,56 @@ Parse error: unexpected token: <ID>. Expected <END_OF_INPUT>, ), ::, &&, ;, ||,
| ^^
Parse error: unexpected token: <ID>. Expected <END_OF_INPUT>, ), ::, &&, ;, ||, ->, ==, !=, >, >=, <, or <=.

- e2e_tests/invalid_constraints.p4:52:11-14:
- e2e_tests/invalid_constraints.p4:68:11-14:
| /**************************************************************************/
52 | error here
68 | error here
| ^^^^
Parse error: unexpected token: <ID>. Expected <END_OF_INPUT>, ), ::, &&, ;, ||, ->, ==, !=, >, >=, <, or <=.

- e2e_tests/invalid_constraints.p4:60:5-30:
- e2e_tests/invalid_constraints.p4:76:5-30:
|
60 | ternary_key::prefix_length
76 | ternary_key::prefix_length
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Type error: expression of type ternary<32> has no field 'prefix_length'

- e2e_tests/invalid_constraints.p4:70:5-19:
- e2e_tests/invalid_constraints.p4:86:5-19:
|
70 | 0x0F0F :: value
86 | 0x0F0F :: value
| ^^^^^^^^^^^^^^^
Type error: expression of type int has no field 'value'

- e2e_tests/invalid_constraints.p4:77:42-46:
- e2e_tests/invalid_constraints.p4:93:42-46:
|
77 | -0x0F0F == -0o01234567 -> !false && -false
93 | -0x0F0F == -0o01234567 -> !false && -false
| ^^^^^
Type error: expected type int, got bool

- e2e_tests/invalid_constraints.p4:84:33:
|
84 | !false -> -8 == -0b1000 || !1
| ^
- e2e_tests/invalid_constraints.p4:100:33:
|
100 | !false -> -8 == -0b1000 || !1
| ^
Type error: expected type bool, got int

- e2e_tests/invalid_constraints.p4:92:5-21:
|
92 | optional_key > 10;
| ^^^^^^^^^^^^^^^^^
- e2e_tests/invalid_constraints.p4:108:5-21:
|
108 | optional_key > 10;
| ^^^^^^^^^^^^^^^^^
Type error: operand type optional<32> does not support ordered comparison

- e2e_tests/invalid_constraints.p4:102:5-13:
- e2e_tests/invalid_constraints.p4:118:5-13:
|
102 | ::unknown > 10;
118 | ::unknown > 10;
| ^^^^^^^^^
Type error: unknown attribute 'unknown'

- e2e_tests/invalid_constraints.p4:113:1-9:
- e2e_tests/invalid_constraints.p4:129:1-9:
| headers.ethernet.ether_type == 0x86DD;
113 | ::unknown > 10;
129 | ::unknown > 10;
| ^^^^^^^^^
Type error: unknown attribute 'unknown'

- e2e_tests/invalid_constraints.p4:157:5-13:
- e2e_tests/invalid_constraints.p4:173:5-13:
| // An invalid constraint to ensure error messages are sensible.
157 | ::unknown > 10;
173 | ::unknown > 10;
| ^^^^^^^^^
Type error: unknown attribute 'unknown'
16 changes: 16 additions & 0 deletions e2e_tests/invalid_constraints.p4
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2021 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "common.p4"

control invalid_constraints(inout headers_t headers,
Expand Down
16 changes: 8 additions & 8 deletions e2e_tests/valid_constraints.expected.output
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ e2e_tests/table_entries/acl_table_1.pb.txt
=== Output ===
All entries must satisfy:

e2e_tests/valid_constraints.p4:22:5-65:
e2e_tests/valid_constraints.p4:38:5-65:
| // Either wildcard or exact match (i.e., 'optional' match).
22 | hdr.ipv4.dst_addr::mask == 0 || hdr.ipv4.dst_addr::mask == -1;
38 | hdr.ipv4.dst_addr::mask == 0 || hdr.ipv4.dst_addr::mask == -1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But your entry does not.
Expand Down Expand Up @@ -84,9 +84,9 @@ e2e_tests/table_entries/optional_match_table_invalid_1.pb.txt
=== Output ===
All entries must satisfy:

e2e_tests/valid_constraints.p4:100:5-32:
e2e_tests/valid_constraints.p4:116:5-32:
| // A real constraint: only wildcard match is okay.
100 | hdr.ipv4.dst_addr::mask == 0;
116 | hdr.ipv4.dst_addr::mask == 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But your entry does not.
Expand All @@ -107,9 +107,9 @@ e2e_tests/table_entries/optional_match_table_valid_max_priority.pb.txt
=== Output ===
All entries must satisfy:

e2e_tests/valid_constraints.p4:102:5-27:
e2e_tests/valid_constraints.p4:118:5-27:
| // A constraint on metadata.
102 | ::priority < 0x7fffffff;
118 | ::priority < 0x7fffffff;
| ^^^^^^^^^^^^^^^^^^^^^^^

But your entry does not.
Expand All @@ -123,8 +123,8 @@ e2e_tests/table_entries/reject_all_entries_1.pb.txt
=== Output ===
All entries must satisfy:

e2e_tests/valid_constraints.p4:14:1-5:
14 | false
e2e_tests/valid_constraints.p4:30:1-5:
30 | false
| ^^^^^

But your entry does not.
Expand Down
16 changes: 16 additions & 0 deletions e2e_tests/valid_constraints.p4
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2021 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "common.p4"

control valid_constraints(inout headers_t hdr,
Expand Down
16 changes: 16 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/bash
# Copyright 2020 The P4-Constraints Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

#
# Formats source files according to Google's style guide. Requires clang-format.
#
Expand Down
16 changes: 16 additions & 0 deletions gutils/proto.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2022 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "gutils/proto.h"

#include <fcntl.h>
Expand Down
18 changes: 18 additions & 0 deletions gutils/proto.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright 2022 The P4-Constraints Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_PROTO_H_
#define THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_PROTO_H_

Expand Down
16 changes: 16 additions & 0 deletions gutils/status.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2022 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "gutils/status.h"

#include <string>
Expand Down
18 changes: 18 additions & 0 deletions gutils/status.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright 2022 The P4-Constraints Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_STATUS_H_
#define THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_STATUS_H_

Expand Down
15 changes: 15 additions & 0 deletions gutils/testing_test.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright 2023 The P4-Constraints Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "gutils/testing.h"

Expand Down
Loading

0 comments on commit e8f2f4b

Please sign in to comment.