janakr | f00d624 | 2018-03-06 14:56:45 -0800 | [diff] [blame] | 1 | // Copyright 2018 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.devtools.build.lib.skyframe; |
| 16 | |
nharmata | 4ec695c | 2019-02-19 08:30:22 -0800 | [diff] [blame] | 17 | import com.google.common.collect.ImmutableList; |
shahan | 602cc85 | 2018-06-06 20:09:57 -0700 | [diff] [blame] | 18 | import com.google.devtools.build.lib.actions.FileStateValue; |
| 19 | import com.google.devtools.build.lib.actions.FileValue; |
janakr | f00d624 | 2018-03-06 14:56:45 -0800 | [diff] [blame] | 20 | import com.google.devtools.build.lib.skyframe.serialization.testutils.FsUtils; |
| 21 | import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester; |
janakr | f00d624 | 2018-03-06 14:56:45 -0800 | [diff] [blame] | 22 | import com.google.devtools.build.lib.vfs.PathFragment; |
| 23 | import org.junit.Test; |
| 24 | import org.junit.runner.RunWith; |
| 25 | import org.junit.runners.JUnit4; |
| 26 | |
| 27 | /** Tests for {@link FileValue}. */ |
| 28 | @RunWith(JUnit4.class) |
| 29 | public class FileValueTest { |
| 30 | @Test |
| 31 | public void testCodec() throws Exception { |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 32 | SerializationTester serializationTester = |
| 33 | new SerializationTester( |
janakr | f00d624 | 2018-03-06 14:56:45 -0800 | [diff] [blame] | 34 | // Assume we have adequate coverage for FileStateValue serialization. |
| 35 | new FileValue.RegularFileValue( |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 36 | FsUtils.TEST_ROOTED_PATH, FileStateValue.NONEXISTENT_FILE_STATE_NODE), |
nharmata | 4ec695c | 2019-02-19 08:30:22 -0800 | [diff] [blame] | 37 | new FileValue.DifferentRealPathFileValueWithStoredChain( |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 38 | FsUtils.TEST_ROOTED_PATH, |
nharmata | 4ec695c | 2019-02-19 08:30:22 -0800 | [diff] [blame] | 39 | FileStateValue.DIRECTORY_FILE_STATE_NODE, |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 40 | ImmutableList.of(FsUtils.TEST_ROOTED_PATH)), |
nharmata | 4ec695c | 2019-02-19 08:30:22 -0800 | [diff] [blame] | 41 | new FileValue.DifferentRealPathFileValueWithoutStoredChain( |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 42 | FsUtils.TEST_ROOTED_PATH, FileStateValue.DIRECTORY_FILE_STATE_NODE), |
nharmata | 4ec695c | 2019-02-19 08:30:22 -0800 | [diff] [blame] | 43 | new FileValue.SymlinkFileValueWithStoredChain( |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 44 | FsUtils.TEST_ROOTED_PATH, |
nharmata | 4ec695c | 2019-02-19 08:30:22 -0800 | [diff] [blame] | 45 | new FileStateValue.RegularFileStateValue( |
| 46 | /*size=*/ 100, /*digest=*/ new byte[] {1, 2, 3, 4, 5}, /*contentsProxy=*/ null), |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 47 | ImmutableList.of(FsUtils.TEST_ROOTED_PATH), |
nharmata | 4ec695c | 2019-02-19 08:30:22 -0800 | [diff] [blame] | 48 | PathFragment.create("somewhere/else")), |
| 49 | new FileValue.SymlinkFileValueWithoutStoredChain( |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 50 | FsUtils.TEST_ROOTED_PATH, |
janakr | f00d624 | 2018-03-06 14:56:45 -0800 | [diff] [blame] | 51 | new FileStateValue.RegularFileStateValue( |
| 52 | /*size=*/ 100, /*digest=*/ new byte[] {1, 2, 3, 4, 5}, /*contentsProxy=*/ null), |
nharmata | f93c72c | 2020-03-13 14:22:10 -0700 | [diff] [blame] | 53 | PathFragment.create("somewhere/else"))); |
| 54 | FsUtils.addDependencies(serializationTester); |
| 55 | serializationTester.runTests(); |
janakr | f00d624 | 2018-03-06 14:56:45 -0800 | [diff] [blame] | 56 | } |
| 57 | } |