testperm

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testperm 提供只供测试使用的文件权限前提探针。

职责:施加读/写限制,直接尝试对应操作,并在当前机器无法表达限制时 skip。 边界:只服务测试辅助,不参与生产运行时;不检查 euid,不改变运行身份,不注入生产错误。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DenyRead

func DenyRead(t testing.TB, path string)

DenyRead 清除 path 的全部读 permission bits,并用一次真实读探针确认限制。

参数:t 是测试句柄;path 是已存在的普通文件。 返回:无;限制生效则返回给调用点继续执行,限制失效则恢复现场并 skip。 注意:目录不是本入口的目标;无关探针错误不会被转换成 skip。

func DenyWrite

func DenyWrite(t testing.TB, path string)

DenyWrite 清除 path 的全部写 permission bits,并用一次真实写探针确认限制。

参数:t 是测试句柄;path 是已存在的目录或普通文件。 返回:无;限制生效则返回给调用点继续执行,限制失效则恢复现场并 skip。 注意:只有 errors.Is(err, fs.ErrPermission) 才算限制生效;其他探针错误会使测试失败。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL